print statement creates key in hash with reference to empty array??
- From: "rhorizon74" <rhorizon74@xxxxxxxxx>
- Date: 31 Jan 2006 08:24:06 -0800
In the code below the print val statement actually creates an key 'ABC'
in the hash if it does not exist ( i wanted to print the value of the
0th element in an array , the reference to which is stored in a hash
with key 'ABC').
Why should a print create a new key, shouldnt it just print undefined,
and not create any new key.
Thank you
Code:
use strict;
use Data::Dumper;
&main();
sub main
{
my %a;
my $aref = \%a;
print "val: @{$aref->{ABC}}[0]\n";
print Dumper($aref)."\n";
}
Output:
val:
$VAR1 = {
'ABC' => []
};
.
- Follow-Ups:
- Re: print statement creates key in hash with reference to empty array??
- From: it_says_BALLS_on_your forehead
- Re: print statement creates key in hash with reference to empty array??
- From: A. Sinan Unur
- Re: print statement creates key in hash with reference to empty array??
- Prev by Date: Re: Why does Net::SFTP trigger my die handler when no errors?
- Next by Date: Re: print statement creates key in hash with reference to empty array??
- Previous by thread: Perl 6.x , please offer PREPEND as well as APPEND
- Next by thread: Re: print statement creates key in hash with reference to empty array??
- Index(es):
Relevant Pages
|