in reply to Re^2: 'g' flag w/'qr'
in thread 'g' flag w/'qr'

You're switching on ?x too late in the regular expression:

#!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 \@matche +s; }; 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' ];

The first whitespace is not governed by ?x.

Replies are listed 'Best First'.
Re^4: 'g' flag w/'qr'
by perl-diddler (Chaplain) on May 29, 2016 at 12:38 UTC
    Bingo on that one... Too many spaces before telling it to ignore spaces...erk!