[Chicago-talk] Deprecated use of hash as a reference
Steven Lembark
lembark at wrkhors.com
Thu Apr 8 12:02:05 PDT 2010
On Thu, 08 Apr 2010 11:21:27 -0500
Brad Doty <bdoty at eqtc.com> wrote:
> Imran & Lee,
>
> Well, that's the obvious choice, isn't it?
>
> BTW, I still think it is STUPID that Perl hides all the %'s and @'s in
> almost every practical use of a hash and array. I understand why it's
> $array[0], but I DON'T like it! If it's an array, it should use the
> array symbol!
It does use the array symbol: [] is the symbol for
accessing an array.
$ is the symbol for retrieving a scalar.
@ is the symbol for retrieving a list.
q.e.d., $array[ $i ] indicates the extraction a
scalar ('$') out of the array ([]).
extraction of a list from the array uses
@foo[ $begin .. $end ]
for the same reason: [] indicates "foo" is an array
"@" indicates a list extracted.
ditto @bar{ qw( bletch blort blam ) } taking
a list from the hash 'bar'.
It's all out in the open.
The difference is that
$foo{ bar } = bletch 1;
@foo{ bar } = bletch 1;
Produce a different context for the call to bletch.
--
Steven Lembark 85-09 90th St.
Workhorse Computing Woodhaven, NY, 11421
lembark at wrkhors.com +1 888 359 3508
More information about the Chicago-talk
mailing list