feedback Tim Klein was [CLUE-Tech] removing spaces from filenames?

Timothy C. Klein teece at silverklein.net
Tue Nov 19 19:36:37 MST 2002


* Dave Price (davep at kinaole.org) wrote:
> On Sun, Nov 17, 2002 at 04:18:11PM -0700, Timothy C. Klein wrote:
> > 
> > #!/usr/bin/perl
> > 
> > use strict;
> > use warnings;
> > 
> > # Change these to set up the desired replacement
> > my $glob_pat = "*";
> > my $out_pat = " ";
> > my $replace_pat = "_";
> > 
> > foreach my $file (glob "$glob_pat") {
> > 	my $newfile = $file;
> > $newfile =~ s/$out_pat/$replace_pat/;
> > 	if (-e $newfile) {
> > 		warn "Can't rename $file to $newfile: $newfile exists.\n";
> > 	} elsif (rename $file, $newfile) {
> > 		## Sucess, the work is already done.
> > 	} else {
> > 		warn "Rename of $file to $newfile failed: $!\n";
> > 	}
> > }
> 
> I needed to change the search line to:
> $newfile =~ s/$out_pat/$replace_pat/g;
> 
> To get more than 1 space in the name ...
> 
> (wish it could recurse)
> 
> aloha,
> dave

Oh yeah, that makes sense.  What I was using it for the last time, I
didn't want more than one match.

Tim
--
==============================================
== Timothy Klein || teece at silverklein.net   ==
== ---------------------------------------- ==
== "Hello, World" 17 Errors, 31 Warnings... ==
==============================================



More information about the clue-tech mailing list