kiat has asked for the wisdom of the Perl Monks concerning the following question:
Just out of curiosity...
An array is prefixed with @ and so when you want to do an array splice, you also use @ to get to the elements:
A hash is prefixed with % but why is a hash splice prefixed with @ and not %?my @array = qw(one two three four five); print "@array[2,3]\n"; # prints three four
Hope someone can enlighten me.my %hash = ( 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', ); print "@hash{'2', '3'}\n"; # prints two three
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array splice vs hash splice
by chas (Priest) on Jun 05, 2005 at 02:37 UTC | |
|
Re: array splice vs hash splice
by Zaxo (Archbishop) on Jun 05, 2005 at 03:14 UTC | |
|
Re: array splice vs hash splice
by brian_d_foy (Abbot) on Jun 05, 2005 at 03:26 UTC |