I have trouble executing a search and replace through all files in a certain 
directory.

I want to replace " _</pat" by "</pat"

Can I match a white-space?

I have tried the following regex:

s/ _\</pat/"</pat"/g

and tried to incorporate it in the following script:

#!/usr/local/bin/perl -w
use strict;
use warnings;
open(INFILE,"<A_Z.xml") || die "Couldn't open file for
reading!\n";
open(OUTFILE,">A_Z.new") || die "Couldn't open file.new
for writing!\n";
while(<INFILE>){
        $_ =~ s/"_\</pat"/"\</pat"/gi; #g for every occurrence, i for 
case-insensitive
        print OUTFILE $_;
}
close INFILE;
close OUTFILE;
rename("A_Z.new","A_Zclean.xml") || die "Couldn't rename the
new file!\n"; #automatically kills the old file

{
local ( $^I, @ARGV ) = ( '.bak', 'B' );
s/\b_\</pat\b/\</pat/g while <>
}

The docs don't answer all my questions. Any help will be highly appreciated.
I wish there was an absolute-beginners list...

Saskia

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to