Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re:x2 Whether to use local()

by grinder (Bishop)
on Mar 15, 2002 at 20:05 UTC ( #152072=note: print w/ replies, xml ) Need Help??

in reply to Re: Whether to use local()
in thread Whether to use local()

I was wondering if someone was going to bring this up. To me, this is the best way to share a variable between two (or more) subroutines.

Just bear in mind, though, that you may receive puzzling errors regarding $new_mail being undefined, depending on where this code appears in the file, and how and when control gets passed to update_mail_list() or read_mail_list().

Best practices would suggest that rathing than enclosing the variable and the referring subs in bare { } braces, you should use a BEGIN { } block. This will ensure that $new_mail gets set up on the lexical pad before you get around to using it.

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Comment on Re:x2 Whether to use local()
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152072]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2015-11-26 00:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (693 votes), past polls