#!perl -w use strict; use Data::Dumper; my $dat = "Just another cats meow"; sub print_matches { my( $re ) = @_; my @matches = $dat =~ /$re/; print "Using $re\n"; print "#matches=%s, matches=%s", scalar(@matches), Dumper \@matches; }; print_matches( qr{ (?x) (\w+) } ); print_matches( qr{(?x) (\w+) } ); __END__ Using (?^: (?x) (\w+) ) #matches=%s, matches=%s1$VAR1 = [ 'another' ]; Using (?^:(?x) (\w+) ) #matches=%s, matches=%s1$VAR1 = [ 'Just' ];