Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Regex variables with delimiters

by jwkrahn (Abbot)
on May 18, 2019 at 00:38 UTC ( [id://11100210]=note: print w/replies, xml ) Need Help??


in reply to Regex variables with delimiters

$regexp = "m?" . <STDIN> . "?";

This won't work because STDIN reads a line which contains a newline at the end which won't match your example.

chomp( my $input = <STDIN> ); $regexp = qr/$input/; if $line =~ ?$regexp? ...

Replies are listed 'Best First'.
Re^2: Regex variables with delimiters
by AnomalousMonk (Archbishop) on May 18, 2019 at 01:31 UTC
    if $line =~ ?$regexp?

    But see the caution about  ?...? here.


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found