Chas Owens wrote:
On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
snip
Silly rhetorical-ness aside, you seem unfamiliar with the term you
introduced to this thread: "string form of a regexp":

$ perl -le'
$a = q{foo};
$b = qr{foo};
print $a;
print $b;
'
foo
(?-xism:foo)

My assertion is that you do not need to make sure your variable is of
the form of $b above, but only that whatever it does contain, there
are no meta characters in it.

I know about the quote regex operator*, but it is not what I was
referring to when I said "string form of a regex".  I was referring to
to a string that contains a a regex.  qr// is just a fancy double
quote that adds a non-capturing group and sets the appropriate options
(in case you did something like qr/foo/i).  The string "(?:-xism:foo)"
is no more or less a regex than the string "foo".


If "qr// is just a fancy double quote" then \b would represent the backspace character and not a word boundary for example:

$ perl -le'my $x = qq/(?i:\bfoo\b)/; my $y = qr/\bfoo\b/i; print for $x, $y'
(?ifo)
(?i-xsm:\bfoo\b)


The object created by qr// *is* a compiled regex:

$ perl -le'my $x = qq/(?i:foo)/; my $y = qr/foo/i; print ref for $x, $y'

Regexp

$ perl -Mre=debug -le'my $y = qr/foo/i'
Freeing REx: `","'
Compiling REx `foo'
size 3 Got 28 bytes for offset annotations.
first at 1
   1: EXACTF <foo>(3)
   3: END(0)
stclass "EXACTF <foo>" minlen 3
Offsets: [3]
        1[3] 0[0] 4[0]
Freeing REx: `"foo"'




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to