[Israel.pm] Direct access to variables from sub

Levenglick Dov-RM07994 DovL at freescale.com
Sun Oct 2 06:08:18 PDT 2005


This is the first time I hear of this magical + operator. What exactly does it do and where can I find the proper documentation (incomprehensible code == job security)

 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
 


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Gaal Yahas
Sent: Sunday, October 02, 2005 3:54 PM
To: david istermann; Perl in Israel
Subject: Re: [Israel.pm] Direct access to variables from sub


On Sun, Oct 02, 2005 at 02:07:33PM +0200, david istermann wrote:
> 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!

Subs can only return scalars or lists: what yours does is return a
*flattened* hash, which cannot be directly subscripted.

You can, however, construct an anonymous hash and indirectly subscript
that:

       $value = +{ your_func() }->{$key};

Although this may turn out not to be a great idea if the guy who maintains
your code finds out where you live.

-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list