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 (Archbishop) 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