Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: Noob could use advice on simplification & optimization

by Anonymous Monk
on May 08, 2012 at 13:03 UTC ( #969448=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Noob could use advice on simplification & optimization
in thread Noob could use advice on simplification & optimization

'my' variables are lexical to the enclosing block. Here, since the variables are declared in the MAIN package, outside of any block, they are global, or visible to all all blocks within the package MAIN.

Almost. They have file scope, they're global to the file. See Lexical scoping like a fox,

$ cat foo1.pl my $foo = qq{i'm in main too ${\__FILE__}\n}; sub foo1 { print $foo; } $ cat foo2.pl my $foo = qq{i'm in main too ${\__FILE__}\n}; sub foo2 { print $foo; } $ perl -e " require $_ for qw/ foo1.pl foo2.pl /; foo1(); foo2(); " i'm in main too foo1.pl i'm in main too foo2.pl


Comment on Re^6: Noob could use advice on simplification & optimization
Download Code
Re^7: Noob could use advice on simplification & optimization
by bgreg (Initiate) on May 09, 2012 at 20:20 UTC
    Got it. Thanks all!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-07-14 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls