[Israel.pm] Direct access to variables from sub

Yosef Meller mellerf at netvision.net.il
Sun Oct 2 07:37:41 PDT 2005

sub test {return (a=>'b',c=>'d')};
print( +{test()}->{a} )'

I'm making a hash reference out of the results of test() using '{}', and 
to make sure perl doesn't see it as the start of a block of code, I use 
the '+' charachter.

david istermann wrote:
> Hi,
> I have a subroutine which returns a hash (a real hash, not a
> reference). I'd like to directly access an entry inside this hash
> bypassing variable assignment, however I cannot seem to successfully
> tell Perl my intention... Please help!
> David.
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl

  Keep on rocking in a free world!

More information about the Perl mailing list