in reply to Re^2: Simple Perl file rename
in thread Simple Perl file rename
In any UNIX-like shell, when you specify a filename glob (i.e. a filename with wildcards) on the shell commandline, it is the shell, and not the program you are calling, which expands the glob.
So yes, when you call
rename.pl *.txtthe shell expands the *.txt to all matching files, and the Perl script finds the already expanded args in its @ARGV.
If you want the script to do the glob expansion, you'd have to enclose the argument in single quotes, i.e. call it like this:
somescript.pl '*.txt'
Then the Perl script finds exactly one arg in @ARGV, namely *.txt and you would have to find some way to do the expansion.
With Larry's script however, I typically feed it ALL the files by matching *; it will only act on those files which max the regexp given as the first argument anyway, all others are skipped. Of course that requires some care in constructing the regexp.
|
|---|