perl passing parameters on windows -
i have following code :
$op = shift or die "usage: rename expr [files]\n"; chomp(@argv = <stdin>) unless @argv; print "$op"; ( @argv ) { print "$_"; $was = $_; eval $op; die $@ if $@; rename ( $was, $_ ) unless $was eq $_; }
it produces expected result on linux machine, i.e. when run
perl massrenamer.pl 's/\.txt/\.txtla/' *.txt
i proper results. try execute same thing on windows machine, strawberry perl installed like
perl massrenamer.pl 's/\.txt/\.txtla/' *.txt
and
perl massrenamer.pl "s/\.txt/\.txtla/" *.txt
and
perl massrenamer.pl 's/\.txt/\.txtla/' "*.txt"
but no result. help?
wilcard expansion done shell, not when parameter enclosed between quotes, on windows port perl scripts there module win32::autoglob see question
a quick fix: replace ( @argv ) ( glob "@argv" )
$op = shift or die "usage: rename expr [files]\n"; chomp(@argv = <stdin>) unless @argv; print "$op"; ( glob "@argv" ) { print "$_"; $was = $_; eval $op; die $@ if $@; rename ( $was, $_ ) unless $was eq $_; }
Comments
Post a Comment