Perl question: array member of referenced hash
Noam Rathaus
noamr at beyondsecurity.com
Sat Oct 24 22:05:16 IST 2009
Shachar,
{ } in Perl are casting when they surround a value
And the second set of { } around the 'a' mean variable of Hash
2009/10/24 Shachar Shemesh <shachar at shemesh.biz>:
> Dov Grobgeld wrote:
>
> Noam beat me to it, but here's perl solution without additional variables:
>
> #!/usr/bin/perl
>
> %hash = (a=>['moo','goo','woo'],
> foo=>3,
> baz=>5);
>
> $ref = \%hash;
> foreach my $elem (@{$ref->{a}})
>
> Hi Dov,
>
> Yes, it works. Now can you, please, explain to me why? What is the role of
> each bracket you used (and its location)?
>
> Shachar
>
> --
> Shachar Shemesh
> Lingnu Open Source Consulting Ltd.
> http://www.lingnu.com
>
> _______________________________________________
> Linux-il mailing list
> Linux-il at cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
>
More information about the Linux-il
mailing list