Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

3 Examples of Multiple-Word Search n Replace

by chunlou (Curate)
on Jun 27, 2003 at 18:02 UTC ( [id://269680] : perlmeditation . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %ch = ('green' => 'lousy', 
              'blue'  => 'cool', 
    ...
    
    I have a green hat, blue shirt, plus a pink jacket
    I have a lousy hat, cool shirt, plus a mini jacket
    
  2. or download this
    use Tie::RegexpHash;
    my %sr;
    ...
    
    I hate you i HAte u i HH@@@TTeE eww i HA@AaaTTee u I HATE YOU!
    I love you i love you i love you i love you I love you!
    
  3. or download this
    use Tie::RegexpHash;
    my %sr;
    ...
    
    Programmers Honoured at Harbour Centre
    Programmers Honored at Harbor Center
    
  4. or download this
    use Tie::RegexpHash;
    my %sr;
    ...
    
    Programmers Honoured at Harbour Centre
    Programmers onorH at arbor enter
    
  5. or download this
    use Regexp::Subst::Parallel;
    my @sr =( qr/\b(h)arbour\b/i     => '$1arbor',
    ...
    
    Man Honoured at Harbour Centre by the Lift
    Man Honored at Harbor Center by the Elevator