in reply to changing data

well, I can lend a hand on your regex:

foreach my $line ( grep { $_ =~ /<META NAME="AA\./ } <FILEHANDLE> ) { $line =~ s/"AA\.(.+?)"/"$1"/; }

the grep filters the input from the file so you only have to deal with the lines that have the meta tags in question. Then you don't need to escape quotes and equal in the regex, rendering your regex much more legible. Reading in directly from the filehandle will also use up less memory at any given point since you don't have to read in the whole file.

note that this general technique of going line by line will only work for you if the meta tag isn't split up across multiple lines

Replies are listed 'Best First'.
Re: Re: changing data
by Anonymous Monk on Feb 25, 2002 at 18:38 UTC
    I tried it with this but the regular expression part isnt working and it seems to only cover one directory.
    @files = glob('c:\perl\bin\newer\*'); foreach $db (@files) { open(DATA, "$db") or die "File does not open: $!"; @data = (<DATA>); close (DATA); open(DATA, ">$db") or die "File not open: $!"; foreach $line (@data) { $line =~ s/<meta name\=\AA\.\"/<meta name\=\\./gi; print DATA $line; } close(DATA); }
      Well, my post did not address traversing directories. I'd encourage you to try substituting everything but the first line of your outer foreach loop with what I suggested. If you would like further explanation of what I've done, I'll gladly provide it.