I don't see how that could possibly work, since you are declaring the value
of $hash{1} to be $domain, which has not been initialized.  You are
declaring $hash{1} to be the VALUE of $domain.  When you change $domain
later, this won't update your hash retroactively.  Maybe this is just a typo
in your post?

-----Original Message-----
From: Tim Yohn [mailto:tyohn@;alabanza.com]
Sent: Thursday, November 07, 2002 9:13 AM
To: [EMAIL PROTECTED]
Subject: Population of variables in hash values...


Hey All,

Is there an easy way to have variables in the value of a hash that are
not populated until the value of the hash is used... for example:

my($domain);
my(%hash) = (
        1 => "$domain"
);

print_domain("test.com");

sub print_domain() {
        my($domain) = @_;

        print $hash{'1'};
}

What ends up happening is the printing of a null string (I understand
why since $domain didn't contain a value when the hash was initially
populated)... however what I would like to have happen is the $domain
value of the hash be populated when it is called in the sub, thus
printing "test.com".  I've tried references in the hash (i.e. 1 =>
"\$domain") however then I just received the SCALAR(memaddr) as output. 
Any suggestions that might help point me in the right direction would be
greatly appreciated.

Thanks,
Tim.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to