Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Can I from within a module access variables from the calling program?

by kcott (Abbot)
on Oct 25, 2012 at 12:20 UTC ( #1000843=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Can I from within a module access variables from the calling program?
in thread Can I from within a module access variables from the calling program?

I may be missing the point you're making but HJO's statement referred to global variables. Other examples with variables explicitly declared as global:

$ perl -le 'local $foo = "whatever"; print $main::foo;' whatever
$ perl -le 'our $foo = "whatever"; print $main::foo;' whatever

-- Ken


Comment on Re^3: Can I from within a module access variables from the calling program?
Select or Download Code
Re^4: Can I from within a module access variables from the calling program?
by MidLifeXis (Monsignor) on Oct 25, 2012 at 12:31 UTC

    Very true, but the OP also was using my variables in their original code. our, local, or undeclared (as you demonstrated) would work.

    --MidLifeXis

      All good - I see the connection: "it didn't work" was not referring to $main::foo (in the sentence preceding it) but rather $main::log_name (near the end of the post).

      -- Ken

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-07-03 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls