Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: 'g' flag w/ 'qr'

by Athanasius (Archbishop)
on May 29, 2016 at 09:29 UTC ( [id://1164436]=note: print w/replies, xml ) Need Help??


in reply to Re^2: 'g' flag w/'qr'
in thread 'g' flag w/'qr'

I’m guessing you’re running a fairly old version of Perl? On 5.20.2, I get:

Unknown regexp modifier "/g" at 1645_SoPW.pl line 18, near "= "

— which is clear. But on 5.12.3, I get:

Bareword found where operator expected at 1645_SoPW.pl line 18, near " +qr{ (\w+) }gx" syntax error at 1645_SoPW.pl line 18, near "qr{ (\w+) }gx"

— which isn’t. In any case, the “deprecated” message you’re seeing is related only indirectly to the presence of a /g modifier on a qr// term. The Perl compiler is simply confused as to what the syntax is supposed to mean, and its (incorrect) guess leads it to find a construct which you never intended and which happens to be deprecated.

Actually, the qr// syntax was introduced in Perl 5.005,1 which was released in 1998. The first edition of the Camel Book to document qr// was the third edition, published in July, 2000 (4 months after the release of Perl 5.6). The section “Pattern-Matching Operators” in Chapter 5 draws a distinction between those modifiers which apply to a regex (are are therefore applicable to qr//) and those which apply to an operator (and are therefore applicable only to m// and s///).2 The /g modifier falls in the second category. So, AFAICT, putting a /g modifier on a qr// term is not “deprecated,” as it was never allowed in the first place.

1Update (May 30, 2016): See perl5005delta#New qr// operator.
2Compare the tables on pages 147 and 150.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1164436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-18 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found