Help for this page

Select Code to Download


  1. or download this
    my $string = "abababa";
    $string = reverse $string;
    $string =~ s/b/x/;
    $string = reverse $string;
    print $string,$/;
    
  2. or download this
    my $string = "abababa";
    my $ri  = rindex( $string, 'b' );
    substr( $string, $ri, 1) =  'x';
    print $string,$/;
    
  3. or download this
    use Benchmark 'cmpthese';
    
    ...
    neglook 719252/s      --    -19%    -20%
    rindex  888889/s     24%      --     -1%
    sexeger 901442/s     25%      1%      --
    
  4. or download this
    use Benchmark 'cmpthese';
    use strict;
    ...
    sexeger  884695/s     48%     23%      0%      --    -71%
    neganch 3003003/s    404%    319%    239%    239%      --