Is it sensible to move the contents of the batch file into Perl? You can use the Perl variable %ENV to manipulate the environment that will be seen by a program run using backticks.
True laziness is hard work
| [reply] |
The perl program is capable of setting environment variables - eg:
$ENV{FOO} = 'foo';
but, for your script to be able to do that, you need to know in advance the names of these env vars, and the values they need to take on.
If that's not the case, then things get a bit more complicated. I would probably open the batch file for reading and parse its contents for the settings that need to be made:
use strict;
use warnings;
open RD, '<', 'foo.bat' or die $!;
while(<RD>) {
if($_ =~ /set\s/i) {
my @v = split /=/, $_;
my $n = (split /\s/, $v[0])[-1];
$ENV{$n} = $v[1];
print "\$ENV{$n} : $ENV{$n}\n";
}
}
my @progname_output = `progname l`;
The regexes might need some adapting, depending upon what the contents of the batch file can be.
Cheers, Rob | [reply] [d/l] [select] |
| [reply] |
Here's one who the music of his own vain tongue doth ravish like enchanting harmony.
| [reply] |
If you were an intern and told you should perform an appendectomy, would you expect to have to look up how on the internet?
Programming is more complex than most surgery.
Accepting tasks for which you are not equipped is foolish. Being allocated tasks for which you are not equipped is bordering on criminal.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |