On 12/22/06, Michael G Schwern <schwern@gmail.com> wrote:
> demerphq wrote:
> > If you truely wish to match nothing use the pattern /(?:)/
>
> Or just remove the match entirely since that will match anything.
Well yeah. The reason I mentioned (?:) was that I assumed that this
issue came from something like:
if ($foo=~/$bar/) { .... }
which suffers from the problem that if $bar is empty it wont do what
most people expect. Consider:
perl -le"$_='foo'; /(foo)/; $x=''; print qq($1) if /$x/;"
will output: 'foo'
The way around it is to change the pattern to
if ($foo=~/(?:)$bar/) { .... }
or to
if ($foo=~/(?#)$bar/) { .... }
Personally I dont like the behaviour of the empty pattern and would
just as soon see it deprecated and removed.
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"