oha has asked for the wisdom of the Perl Monks concerning the following question:
some days ago, speaking with another monk, i got this code:
it should append the array whose name is $a[0]. I expected to get an error if @a is empty, i'll get a undefined from $a[0]!.push @{$a[0]}, "foo";
gives:use Data::Dumper; print Dumper(\@a); push @{$a[0]}, "foo"; print Dumper(\@a);
why perl vivify an anonymous array in @a?$VAR1 = []; $VAR1 = [ [ 'foo' ] ];
update: added bold to important text
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: push undefined and vivification
by BrowserUk (Patriarch) on Jan 17, 2004 at 22:34 UTC | |
by edan (Curate) on Jan 18, 2004 at 06:02 UTC | |
by oha (Friar) on Jan 18, 2004 at 12:07 UTC | |
by Anonymous Monk on Jan 18, 2004 at 12:53 UTC | |
|
•Re: push undefined and vivification
by merlyn (Sage) on Jan 17, 2004 at 22:20 UTC | |
|
Re: push undefined and vivification
by Anonymous Monk on Jan 18, 2004 at 09:03 UTC | |
|
Re: push undefined and vivification
by mrpeabody (Friar) on Jan 19, 2004 at 01:04 UTC |