ExReg has asked for the wisdom of the Perl Monks concerning the following question:
Having a bad morning remembering. I have a script that runs a bunch of checks. It uses a module that contains an array of checks. There are variables defined in the script that are in the checks in the module that I can get to work. Here is a simplified example:
checks.pl use strict; use warnings; use check_module; my $home_dir = '/home/mine/'; for my $check ( @checks ) { print "Checking $check->{name}\n"; `check->{script}`; } check_module.pm package check_module; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(@checks); our @checks = ( { name => "Anybody home?", script => qq/echo $home_dir/, }, ); 1;
When I run it I get
Checking Anybody home?How do I get the $home_dir to evaluate so that I get
Checking Anybody home? /home/mine
I hope I typed this simplified example OK. It is on another system that cannot use CPAN or anything else except that which is installed. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable declared in script, used by module, and used in script (updated)
by AnomalousMonk (Archbishop) on May 16, 2018 at 17:28 UTC | |
by ExReg (Priest) on May 16, 2018 at 17:47 UTC | |
|
Re: Variable declared in script, used by module, and used in script
by pryrt (Abbot) on May 17, 2018 at 14:01 UTC | |
|
Re: Variable declared in script, used by module, and used in script
by Anonymous Monk on May 17, 2018 at 08:45 UTC | |
|
Re: Variable declared in script, used by module, and used in script
by KolassaRaptor (Monk) on May 17, 2018 at 14:49 UTC | |
by AnomalousMonk (Archbishop) on May 17, 2018 at 20:01 UTC |