regex bug (comments within regex not as robust)

K

kg.google

Code:

if
(
$x =~
/
\d+ # this slash / generates an error
/x
)
{
}

version:
activestate perl 5.8.7

regards,
Kiriakos Georgiou
 
D

Dave

Code:

if
(
$x =~
/
\d+ # this slash / generates an error
/x
)
{
}

version:
activestate perl 5.8.7

regards,
Kiriakos Georgiou

This is not a bug. The compiler doesn't see the /x switch until it has found
the limits of the regex, so the / in the comment gives it a false ending
(see the footnote on p148 of the camel book). If you want to use / in your
comments use {} (or something else)as regex delimiters.
 
D

Dave

Dave said:
This is not a bug. The compiler doesn't see the /x switch until it has
found the limits of the regex, so the / in the comment gives it a false
ending (see the footnote on p148 of the camel book). If you want to use /
in your comments use {} (or something else)as regex delimiters.

and also the perlre manpage where the /x switch is explained says:

Note that you have to be careful not to include the pattern delimiter in
the comment--perl has no way of knowing you did not intend to close the
pattern early
 
P

Paul Lalli

Code:

if
(
$x =~
/
\d+ # this slash / generates an error
/x
)
{
}

version:
activestate perl 5.8.7

I don't know how you can call it a bug when this limitation of the /x
feature are perfectly well documented in
`perldoc perlre`

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top