Tim Yohn wrote:
>
> Hey All,
Hello,
> 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.
Try using a reference to the scalar variable.
my $domain;
my %hash = ( 1 => \$domain );
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]