in reply to Re: Perl style... help me figure this out.
in thread Perl style... help me figure this out.
That's quite simple. If the only thing you could ever write between the curly and the square bracket is a -> and you have to write it always, then why should you have to write it at all?
It's a convenient shortcut that may be used no matter whether you are chaining array or hash subscriptions. $AoA[1][4], $HoH{some}{thing}, $AoH[1]{whatever}, $HoA{barf}[42], ...
The arrow at the beginning though is important. $A[0] is the first element of the array @A, $A->[0] on the other hand is the first element of the array referenced by $A. Because arrays and hashes may only store scalars (strings, numbers or references) you do not need the arrow between the subscriptions to distinguish such two cases.
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl style... help me figure this out.
by Riales (Hermit) on Feb 07, 2012 at 15:43 UTC |