Help for this page

Select Code to Download


  1. or download this
    my $str = 'xbaaaaaa' . ('_' x 20) . 'bcccccccccc';
    my $start = $str =~ /a+/ ? $+[0] : 0;
    ...
    my $ext = substr $str, $start, $end - $start;
    $, = " | "; $\ = "\n";
    print $start, $end, $ext;
    
  2. or download this
    my $str = 'xbaaaaaa' . ('_' x 20) . 'bcccccccccc';
    $str =~ /(?!)/g;   # A match that always fails, resetting pos()
    ...
    my $ext = substr $str, $start, $end - $start;
    $, = " | "; $\ = "\n";
    print $start, $end, $ext;