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:  <%-{-{-{-<