in reply to Can I from within a module access variables from the calling program?
Though in your particular case, the module "pulling information" from the main script about the log file name is silly. Instead the main script should "push information" to the module. For example:
use v5.10; use strict; use warnings; BEGIN { package Some::Module; no thanks; our $LOGFILE; sub what_is_logfile { say "logfile is $LOGFILE"; } }; package main; use Some::Module; my $log = 'foo.txt'; $Some::Module::LOGFILE = $log; Some::Module->what_is_logfile;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Can I from within a module access variables from the calling program?
by HJO (Acolyte) on Oct 25, 2012 at 13:10 UTC |
In Section
Seekers of Perl Wisdom