Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Purpose of the "caret" character in "qr" regex output

by GrandFather (Saint)
on Jul 31, 2025 at 01:59 UTC ( [id://11165888]=note: print w/replies, xml ) Need Help??


in reply to Purpose of the "caret" character in "qr" regex output

In (?<modifiers>:...) <modifiers> (if present) is some mixture of the 'imopsx' modifiers usually found at the end of a regex. '^' is a modifier in this context that means "use the system default modifiers 'd-imsx'". I'm guessing qr does this to get predictable behavior when $regex is embedded in a larger regex.

Consider:

use strict; use warnings; my $text = 'Abcd'; my $match = 'abcd'; my $regex = qr/$match/; print "No match: '$text', '$match'\n" if $text !~ /$regex/i; print "/i match: '$text', '$match'\n" if $text =~ /$match/i;

Prints:

No match: 'Abcd', 'abcd' /i match: 'Abcd', 'abcd'
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Purpose of the "caret" character in "qr" regex output
by roho (Bishop) on Jul 31, 2025 at 04:34 UTC
    Thank you GrandFather.

    "It's not how hard you work, it's how much you get done."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2025-12-09 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (90 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.