in reply to Accessing module variables
If you have many modules with such data (really password in modules? I'm sure you are aware already of this..) I'd consider a radical change: parse everything with PPI and produce many distinct modules with a lonely accessor, or better put everything in a db.. anyway..
cat Varz.pm package Varz; use Exporter; our @EXPORT = ( $User, $Password, $Url, $Prefix ); our $User = 'Joe'; our $Password = 'Secret123'; our $Url = 'www.example.com'; our $Prefix = 'EX'; 1;
You can just copying vaules from one package to your current one as in:
perl -Mstrict -MVarz -we "our($User, $Password, $Url, $Prefix); map{ $ +main::{$_} = $Varz::{$_} } keys %Varz:: ; print join qq(\n),$User, $ +Password, $Url, $Prefix" Joe Secret123 www.example.com EX
If you want to get a bit mad about symbol table, I recently moved my library
L*
PS you may want to grep out unwanted elements: grep{$_ !~/export|begin/i}keys %Varz::
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing module variables
by talexb (Chancellor) on Apr 19, 2018 at 22:49 UTC |