B
bjlockie
I want to create a wrapper script (testa.pl) that defines variables (like $b) and can execute another perl program (testb.pl) that can access those variables.
I tried:
$ testa.pl 'testb.pl' but it didn't work.
I don't think eval is what I need but 'use' doesn't work on variables.
::::::::::::::
testa.pl
::::::::::::::
#!/usr/bin/perl -w
#use strict;
use warnings;
my $realScript = $ARGV[0];
(defined($realScript)) or die "Must specify a script\n";
print "This is $0\n";
my $b = 10;
eval $realScript;
print $@;
::::::::::::::
testb.pl
::::::::::::::
#!/usr/bin/perl -w
use strict;
use warnings;
print "This is $0, b=$b (should be 10)\n";
I tried:
$ testa.pl 'testb.pl' but it didn't work.
I don't think eval is what I need but 'use' doesn't work on variables.
::::::::::::::
testa.pl
::::::::::::::
#!/usr/bin/perl -w
#use strict;
use warnings;
my $realScript = $ARGV[0];
(defined($realScript)) or die "Must specify a script\n";
print "This is $0\n";
my $b = 10;
eval $realScript;
print $@;
::::::::::::::
testb.pl
::::::::::::::
#!/usr/bin/perl -w
use strict;
use warnings;
print "This is $0, b=$b (should be 10)\n";