Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: 3 Examples of Multiple-Word Search n Replace

by enoch (Chaplain)
on Jun 27, 2003 at 21:20 UTC ( [id://269746] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    my %ch = ('green' => 'lousy',
             'blue'  => 'cool',
    my $regex = qr/$keyList/;
    $str =~ s/$regex/$ch{$1}/g;
    print $str ;
  2. or download this
    my %ch = ('green' => 'lousy',
             'blue'  => 'cool',
    I have a green hat, blue shirt, plus a pink jacket
    I have a lousy fedora, cool shirt, plus a mini jacket