Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
When i try to access the first element of the array, which is [1,2,3] and print its contents, i'm surprised that the following works without generating a warning:my %hash; $hash{"one"} = [[1,2,3],[]];
and produces the correct output: 123print @{@{$hash{"one"}}[0]}, "\n";
That is because when i use:print @{${$hash{"one"}}[0]}, "\n";
a warning message is generated and tells me that @array[0] better be written as $array[0]; Why is it not generating the warning in the first case?my @array = (4,5,6); print @array[0];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: accessing array elements using a reference
by samtregar (Abbot) on May 19, 2008 at 03:55 UTC | |
by Anonymous Monk on May 19, 2008 at 04:06 UTC | |
by ikegami (Patriarch) on May 19, 2008 at 05:26 UTC | |
by Anonymous Monk on May 19, 2008 at 05:42 UTC | |
by BrowserUk (Patriarch) on May 19, 2008 at 06:21 UTC | |
|
Re: accessing array elements using a reference
by grizzley (Chaplain) on May 19, 2008 at 09:53 UTC | |
by Anonymous Monk on May 19, 2008 at 21:42 UTC | |
by grizzley (Chaplain) on May 20, 2008 at 06:37 UTC |