Help for this page

Select Code to Download


  1. or download this
    my %lookup = ( bar => 'thing1', foo => 'thing2');
    $_ = "this has bar and foo\n";
    s/(bar|foo)/$lookup{$1}/g;
    print;                     #=> this has thing1 and thing2
    
  2. or download this
    sub foo { return reverse uc shift }
    $_ = "this has bar and foo\n";
    s/(bar|foo)/foo($1)/eg;
    print;                     #=> this has RAB and OOF