djbryson has asked for the wisdom of the Perl Monks concerning the following question:
So, I tired this... but it ignores my switch (3rd nested if)<meta name="revision" content= "Mon, 05 Jul 2006 23:59:59 GMT"
Forget it... it's only 1 line after the chomp. I need to do 2 passes#!C:\Perl\bin\perl.exe use strict; use File::Find; use File::Slurp; use Time::Local; print "\nRunning ... \n\n"; my $root = "C:/"; # use forward slash, you can use mapped drives. print "changing to $root\n"; chdir $root; my $no_switches=0; my $no_files=0; my @log = (); my $dir; # find (\&Wanted, "department", "managers", "mybranch", "mycity", "myi +nfo", "resources"); find (\&Wanted, "working"); #directories - comman delimited sub Wanted { print "*Processing: $root$File::Find::name \n"; if ($_ =~ /\.htm(l)?$/i) { open(xFILE, $_) or die "ERROR: couldn't open file"; my @file = <xFILE>; foreach my $line (@file) { close (xFILE); if ($line =~ m/<meta[\s\r\n\t]+name="revision"[\s\r\n\t]+conte +nt=[\n]+/i) { open(FILE, ">$_") or die "ERROR: Can't open $_"; chomp($line); if ($line =~ m/(<meta[\s\r\n\t]+name="revision"[\s\r\n\t]+c +ontent=)([\s]+)(.*>)/i) { my $newline = $1.$3; $line =~ s/$line/$newline/; print "Switched: $newline\n"; } print FILE "@file"; # @file array is entire file. close (FILE); print "file overwritten\n"; push @log,"$root$File::Find::name \n\n"; $no_switches++; } # end if } # end for loop $no_files++; } #end if matches filetype else { print "file type not processed\n\n"; } #add $_ if you want + to see URL of file not processed. } # end sub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove line break, then remove spaces (resolved)
by graff (Chancellor) on Jan 21, 2007 at 07:18 UTC | |
by djbryson (Beadle) on Jan 22, 2007 at 18:12 UTC |