Thanks to all for your input. Meanwhile I have continued looking for a solution and have found one.
I invoke the Perl program from a batch file and use '&' to run another batch file generated by the Perl program.
cda.bat
@echo off
cda.pl %* & \bat\aa.bat
cda.pl
#!/usr/bin/perl
######################################################################
# Name: cda.pl
# Desc: CD to alternate directory (optionally to sub-directory).
######################################################################
use strict;
use warnings;
my $dir = "\\newdir";
if (@ARGV) {
$dir .= "\\subdir" . rj(2,'0',shift);
}
my $ofile = "\\bat\\aa.bat";
open(OFILE, '>', $ofile) or die "Error opening $ofile: $!\n";
print OFILE "cd $dir\n";
print OFILE "cls\n";
print OFILE "dir /p /ogen\n";
close OFILE;
exit;
###################################################################
# This subroutine adds commas and right-justifies input number.
###################################################################
sub rj {
my $pad = shift;
my $dlm = shift;
local($_)=@_;
1 while s/(.*\d)(\d\d\d)/$1,$2/;
$_ = ${dlm}x($pad-length($_)).$_;
}
"Its not how hard you work, its how much you get done."
|