On Aug 16, 10:19 am, [EMAIL PROTECTED] (Chas Owens) wrote:
> On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
>
> > On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote:
> > > Basically
> > > it all comes down to this: always use quotemeta unless the variable is
> > > known to contain the string form of a regex.
>
> > No.  It comes down to: "always use quotemeta unless the variable is
> > known to contain the string form of a regexp, or known to not contain
> > any meta characters."

> *** Warning silly rhetorical argument ahead ***
>
> So the foo in /foo/ is not a regular expression because it contains no
> meta-characters?  I don't think anyone would make that argument.  So
> the fact that the string is "know to not contain any meta-characters"
> doesn't change the fact that you know what is inside it and know that
> it is a regular expression and therefore my original rule of thumb
> should stand.
>
> *** end silly rhetorical argument ***

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.

Paul Lalli


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


Reply via email to