Help for this page

Select Code to Download


  1. or download this
    sub dyn_replace {
      my ($replace) = @_;
    ...
      $replace =~ s/\$(\d+)/$groups[$1]/g;
      return $replace;
    }
    
  2. or download this
    my $pat = qr/foo(\d+)bar(\d+)/;
    my $rep = 'x$1y$2';
    my $str = 'foo36bar47';
    $str =~ s/$pat/dyn_replace($rep)/e;
    print "$str\n";