S
Scott Bass
Active State Perl 5.8.6 under Windows
Hi,
Here is an excerpt from a Perl script I wrote:
test.pl:
#!perl
# set pragmas
use strict;
use warnings;
# include desired modules
use Getopt::Long;
use File::Basename;
# glob files specified on the command line
my @files;
while (@ARGV) {
push @files, glob(shift @ARGV);
}
# process each file
my ($dirname, $basename);
while (@files) {
$_ = shift @files;
$basename = basename($_);
$dirname = dirname($_);
print $dirname,"\n";
print $basename,"\n";
}
__END__
Say test.pl is in my path. If in a command window I do:
cd C:\A Path\With Spaces\In It
test.pl *.txt
it works as expected.
However, if I do:
cd c:\
test.pl "C:\A Path\With Spaces\In It\*.txt"
it fails.
How can I change the above script so it will work in both scenarios?
Regards,
Scott
Hi,
Here is an excerpt from a Perl script I wrote:
test.pl:
#!perl
# set pragmas
use strict;
use warnings;
# include desired modules
use Getopt::Long;
use File::Basename;
# glob files specified on the command line
my @files;
while (@ARGV) {
push @files, glob(shift @ARGV);
}
# process each file
my ($dirname, $basename);
while (@files) {
$_ = shift @files;
$basename = basename($_);
$dirname = dirname($_);
print $dirname,"\n";
print $basename,"\n";
}
__END__
Say test.pl is in my path. If in a command window I do:
cd C:\A Path\With Spaces\In It
test.pl *.txt
it works as expected.
However, if I do:
cd c:\
test.pl "C:\A Path\With Spaces\In It\*.txt"
it fails.
How can I change the above script so it will work in both scenarios?
Regards,
Scott