Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: 3 Examples of Multiple-Word Search n Replace

by demerphq (Chancellor)
on Jun 28, 2003 at 09:41 UTC ( [id://269841] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %replace_hash=(foo=>'bar',baz=>'fnord');
    my $regex=compile_regex(keys %replace_hash);
    s/\b($regex)\b/$replace_hash{$1}/g;