[oak perl] test
Sandy Santra
santranyc at yahoo.com
Sun Jan 30 15:18:06 PST 2005
George said there might be problems with the list, so this is a test post.
And here's a snippet of code I wrote recently that I'm very proud of
(considering I haven't even yet finished the regex chapters in the camel
book); and yes, I did crib some of it from the camel book. I know it needs
improvement--any suggestions welcome. (Like how to look over and over
again in each file/directory name for the textstring in case it appears
more times than one...)
Happy new year everyone!
BEGIN PERL SCRIPT:
#find [text string] and delete it from all file and directory names
chdir "c:/temp" or die "cannot chdir to that directory: $!";
foreach $file (glob "*") {
$newfile = $file;
$newfile =~ s/\(1\)//;
if (-e $newfile) {
## warn "can't rename $file to $newfile: $newfile exists\n";
} elsif (rename $file, $newfile) {
## success, do nothing
} else {
warn "rename $file to $newfile failed: $!\n";
}
}
--Sandy Santra
More information about the Oakland
mailing list