Help for this page

Select Code to Download


  1. or download this
    my $str = "the boy walked the dog";
    for ( $str ) {
    ...
      s/boy/girl/;
      s/dog/Audrey II/;
    }
    
  2. or download this
    my $str = "the boy walked the dog";
    my %subs = ( "walked", "fed", "boy", "girl", "dog", "Audrey II" );
    foreach ( keys %subs ) {
      $str =~ s/$_/$subs{$_}/;
    }