in reply to Re^3: Large file processing
in thread Large file processing
my %subs; while (<TEXT>) { my ($s,$r) = (split qr{/})[1,2]; $subs{lc($s)} = $r; } my $pat = join '|', map quotemeta, keys(%subs); #$xml =~ s/>[^>]*\b\K($pat)(?=\b[^>]*<)/$subs{lc($1)}/gi; #$xml =~ s/>[^>]*(?<=\W)\K($pat)(?=\W)(?=[^>]*<)/$subs{lc($1)}/gi; $xml =~ s/>[^>]*(?<=\W)\K($pat)(?=\W)/$subs{lc($1)}/gi;
\K requires 5.10, but you could rewrite it without \K. The important bit is to create one pattern.
It assumes you don't have inputs of the form /A/B/, /B/C/
Update: Added required calls to lc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Large file processing
by arivu198314 (Sexton) on Oct 01, 2010 at 09:09 UTC |