Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Filename fixer

by spm (Acolyte)
on Jul 18, 2001 at 21:56 UTC ( [id://97798] : note . print w/replies, xml ) Need Help??


in reply to Re: Filename fixer
in thread Filename fixer

True, the new code is a lot better. I just threw it here because I had it, a little hack for my friend, and thought someone else might need it... However, I happen to like the $_ variable quite a lot, and try using it as much as possible. Therefore I would rather do:
foreach (<*>) { (my $new = lc) =~ s/ |%20/_/g; $new =~ s/%25//g; rename($_, $new) or warn "can't rename $_ to $new: $!\n"; }
Another thing is that I don't really like using the foreach $variable (@array) {} syntax... I rather use map $variable { } @array if I can't use the $_ variable.. But thanks anyway! spm.