Help for this page

Select Code to Download


  1. or download this
    sub words_before {
        my ( $word, $string ) = @_;
    ...
        my $words_before = () = $before =~ m/(\S+)/g;
        return $words_before;
    }
    
  2. or download this
    print 'There are ' . words_before( $word, $string ) . ' words before "
    +' . $word . '" in the string "' . $string . '"' . "\n";