in reply to Substitute data issue
You could make it look better (but probably less efficient, although you should benchmark this) by using a hash for the substitution.
and replacing the body of the foreach by:my %subst = ( 'AAA' => 'EEE', 'CCC' => 'NEWWORD', 'UUU' => 'NEW', 'ERD' => 'IPK' ); my $pattern = join('|', keys %subst);
Note: this is untested.$line =~ s/($pattern)/$subst{$1}/gi;
Hope this helps, -gjb-
Update: thanks to broquaint for pointing out that I should drop the /e as regex modifier. Silly, I wasn't thinking.
|
|---|