Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    use strict;
    ...
        my( $distance ) = $chunk =~ /dist:.*?(\d+).*?km;/s;
        print STDOUT "$distance\n";
    }
    
  2. or download this
        /dist:    # match 'dist:'
         .*?      # match anything (including newlines), but only until th
    +e next part of the pattern starts to match
    ...
         .*?      # same as before
         km;      # match 'km;' (not needed unless you want to match a num
    +ber of these in one string)
        /s        # treat the whole line as a single string