Mailing List Archive

# in regexp
I think you already have this one, since I have seen some bug reports
name as "comment and regexp...", but I did not have the time to check
more, so well, sorry for the disturbance if it was one:

---- version:
> /usr/local/bin/perl -v

This is perl, version 5.001


Copyright 1987-1994, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.


---- my script bla:
#!/usr/local/bin/perl -w

$_="bla";

/(#bla)/x && print "coucou !\n"; ######## HERE ##########

---- bug:
fregate-~/public_html/test-zone>bla
/(#bla)/: unmatched () in regexp at bla line 5.

---- working variantes:
/(bla)/x ...
/(#bla)/ ...
/(\#bla)/x ...
it works also with an old version (5.000)
people had also the same problem with patchlevel 1m

that's all folks

Good luck !

Thanks for all !

Isil
Re: # in regexp [ In reply to ]
Excerpts from the mail message of Nicolas Thiery:
) I think you already have this one, since I have seen some bug reports
) name as "comment and regexp...", but I did not have the time to check
) more, so well, sorry for the disturbance if it was one:

This is intentional.

From regcomp.c:
else if (*regparse == '#') {
while (*regparse && *regparse != '\n')
regparse++;
regparse++;
continue;

Originally only "(?#comment)" was used for comments in //x. That
was deemed ugly so "#comment\n" is also allowed now:

% perl -de 0
DB<1> $x='hello'
DB<2> p $x =~ /(el)#ignore this comment/x
el
DB<3> q

) ---- working variantes:
) /(\#bla)/x ...

And you already know one of the ways to match # in //x.

--
Tye McQueen tye@metronet.com || tye@doober.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
Re: # in regexp [ In reply to ]
>>>>> "Tye" == Tye McQueen <tye@metronet.com> writes:

Tye> This is intentional.

Tye> Originally only "(?#comment)" was used for comments in //x. That
Tye> was deemed ugly so "#comment\n" is also allowed now:

Wow. I must say, I missed this. Was this added while I was in court? :-)

Time to make another change to the slides... :-)

Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me