Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by MidLifeXis (Monsignor)
on Oct 25, 2012 at 12:08 UTC ( #1000839=note: print w/replies, xml ) Need Help??


in reply to Re: 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?

Subtle difference:

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

--MidLifeXis

  • Comment on Re^2: Can I from within a module access variables from the calling program?
  • Download Code

Replies are listed 'Best First'.
Re^3: Can I from within a module access variables from the calling program?
by kcott (Chancellor) on Oct 25, 2012 at 12:20 UTC

    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

      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://1000839]
help
Chatterbox?
[Rabbi Bob]: We have a Jack Russell: off the leash she is a torpedo against mice, rats, chipmunks and squirrels
[Rabbi Bob]: Doesn't eat them, just snaps, kills, drops and moves on.
[thezip]: Efficient, that one.
[erix]: my dog could do the classic mouse jump (never caught a mouse :)
[erix]: he caught a hare once (must have been a young one...)
virtualsue uses arcane git commands to resurrect a file, gets it back into shape and quits for the day
[GotToBTru]: a few years ago, when we had 3 dogs, the largest of them caught a chipmunk, but did not know what to do with it other than hold it in his mouth
[GotToBTru]: my wife told him to spit it out, so he did
[erix]: yeah, modern dogs are cute tjhat way :)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2017-11-17 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (272 votes). Check out past polls.

    Notices?