[sf-perl] qr{} question
David Alban
extasia at extasia.org
Tue May 26 12:36:34 PDT 2009
On Tue, May 26, 2009 at 12:02 PM, Bill Moseley <moseley at hank.org> wrote:
> Do you really mean to use "xms" or is that just what Perl Critic
> suggests?
/xms gives me a warm fuzzy feeling. but... good thought! i found
that when i omit /x it interpolates both occurrences:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $FOO = 'foo';
my $FOO_REGEX = qr{ $FOO [^#]+ -D $FOO }xms;
print "\nwith /x:\n";
print '$FOO: ', Dumper $FOO;
print '$FOO_REGEX: ', Dumper $FOO_REGEX;
my $BAR = 'bar';
my $BAR_REGEX = qr{ $BAR [^#]+ -D $BAR }ms;
print "\nwithout /x:\n";
print '$BAR: ', Dumper $BAR;
print '$BAR_REGEX: ', Dumper $BAR_REGEX;
prints:
with /x:
$FOO: $VAR1 = 'foo';
$FOO_REGEX: $VAR1 = qr/(?msx-i: foo [^#]+ -D $FOO
)/;
without /x:
$BAR: $VAR1 = 'bar';
$BAR_REGEX: $VAR1 = qr/(?ms-xi: bar [^#]+ -D bar )/;
(i don't care about the now-significant whitespace in the second regex
in this example.)
--
Live in a world of your own, but always welcome visitors.
More information about the SanFrancisco-pm
mailing list