Re: print statement creates key in hash with reference to empty array??
- From: "it_says_BALLS_on_your forehead" <simon.chao@xxxxxxx>
- Date: 31 Jan 2006 08:30:55 -0800
rhorizon74 wrote:
> 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' => []
> };
lookup autovivification.
.
- Follow-Ups:
- References:
- print statement creates key in hash with reference to empty array??
- From: rhorizon74
- print statement creates key in hash with reference to empty array??
- Prev by Date: Re: print statement creates key in hash with reference to empty array??
- Next by Date: Re: print statement creates key in hash with reference to empty array??
- Previous by thread: Re: print statement creates key in hash with reference to empty array??
- Next by thread: Re: print statement creates key in hash with reference to empty array??
- Index(es):
Relevant Pages
|