[boulder.pm] Perl question
Jason Van Slyke
jvanslyk at matchlogic.com
Fri Mar 31 16:02:03 CST 2000
Bob,
Being rudimentary, I floundered around in my ref lib here in my office.
"Learning Perl" shows an example of using the rename function on p135/6.
I'll give this a try too, but you might be able to do something on this
order:
foreach $oldfile (<*.pl>) {
$newfile = lc($oldfile) ;
rename ($oldfile, $newfile) ;
}
Jason
-----Original Message-----
From: Bob Collins [mailto:bcollins at csd.net]
Sent: Friday, March 31, 2000 2:41 PM
To: undisclosed-recipients
Subject: [boulder.pm] Perl question
I have a number files I want to rename to lower case, so I went my "Perl
Cookbook" and found exactly what I needed, "rename" on page 327 in my
book. The "rename" script is sent as an attachment. The script can be
executed as:
rename 'tr/A-Z/a-z/ unless /^Make/' *
This should change files to lowercase. If you understand the " unless
/^Make/ " part I would be interested in an explanation.
I am trying to get it to work in it's simplest form, "rename file.name
newfile.name". I create a file AB.C and try to rename it to ab.c by
executing:
perl -d name AB.C ab.c
I watch it step throug with no errors. The script terminates without
changing anything because $was is equal to $_. Which it is set to in
the script.
This script is attributed to Larry Wall, but I think something must be
missing or incorrect in the script.
Help will be appreciated, I have spent a great deal of time on it with
no success.
--
Regards,
Bob Collins
Mailto:bcollins at csd.net
More information about the Boulder-pm
mailing list