Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Set a variable in calling package

by AnomalousMonk (Archbishop)
on Jan 21, 2018 at 04:40 UTC ( [id://1207617]=note: print w/replies, xml ) Need Help??


in reply to Set a variable in calling package

Or is this more like something you had in mind:

File set_in_importing_script_1.pl
use warnings; use strict; use MyPackage; print $MyPackage::var;
File MyPackage.pm
# MyPackage.pm package MyPackage; use warnings; use strict; use MyUtils; 1;
File MyUtils.pm
# MyUtils.pm package MyUtils; use warnings; use strict; { no strict 'refs'; my $importing_package = (caller 0)[0]; ${ $importing_package . '::var' } = 42; } 1;
Output:
c:\@Work\Perl\monks\TerryBerry>perl set_in_importing_script_1.pl 42


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found