Help for this page

Select Code to Download


  1. or download this
    while($string =~/(simple)/g){ 
    my $postition = pos($string);
    print "most recent match is $1, at position $position\n";
    }
    
  2. or download this
    #!/usr/bin/perl -w
    
    ...
        if($i > 10){ last;}#watch out for infinite loops too if you reset 
    +the position in the while loop
    }
        print "\n";
    
  3. or download this
    $perl simple.pl
    String: "This is a simple thing, just a simple simple thing."
    ...
    $1 is simple, pos($test3) is 16, loop counter is 0
    $1 is simple, pos($test3) is 37, loop counter is 1
    $1 is simple, pos($test3) is 44, loop counter is 2