Help for this page

Select Code to Download


  1. or download this
    my $index2 = -1;
    foreach (1 .. 3) {
        $index2 = index($body, "c", $index2 + 1);
        die "No third 'c'" if $index2 < 0;
    }
    
  2. or download this
    $body =~ /a/g or die "No first 'a'";
    my $index1 = pos($body);
    # my $index1 = index($body, 'a') + length('a');
    
  3. or download this
    my $inbetween = substr($body, $index1, $index2 - $index1);