Hey there, what is the best way of including a Perl so that the contents of it override the existing variables. For example, I have:
<main Perl program>
...
my $comment = "Default\n";
my $resDir = "results";
...
if (@ARGV) {
my $c = shift;
$config = "testing/$c.pm";
unless (my $ret = do $config) {
die "couldn't parse $config: $@" if $@;
die "couldn't do $config: $!" unless defined $ret;
die "couldn't run $config" unless $ret;
}
# Get the output filehandle
$output = getOutputFH();
}
...
<a file in testing/>
$comment = "A not quite default test.";
my $resName = 'notdefault.res';
sub getOutputFH() {
open($fh, ">${resDir}/${resName}.res") or ***
die "Can't open results file: $!";
return $fh;
}
1;
I would like the value of $comment defined in the testing file to
override the value defined in the main program. I would also
like for the value of $resDir to be picked up by the getOutputFH() sub,
however neither of these happens. What is the best way of doing what I'm
trying to acheive here?
(Obviously, in real life, more things are going to be set, but if I can
make this example work, it is a short step to getting the rest working)
The error I get is "Use of uninitialized value in concatenation (.) or
string" at the point marked '***'. I assume it is $resDir not being
defined.
I know that I could simply have a function that returns a hash (list)
that I walk through to set the variables, but I want to keep this as
simple as possible, as I'll be creating lots of little versions of these
testing files, and the more stuff in them, the more there is to go
wrong.
--
Robin <[EMAIL PROTECTED]> JabberID: <[EMAIL PROTECTED]>
Hostes alienigeni me abduxerunt. Qui annus est?
PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663
pgp00000.pgp
Description: PGP signature
