#!/usr/bin/perl -lw
use strict;
# [id://735593]
my $string = '
';
my $regex = qr|
|; # works
# ^^^^^^^ < modified here
if ( $string =~ /$regex/ ) {
print "\$regex matches: $1 and $2";
} else {
print "No match in $regex";
}
my $OPregex= qr|
|; # OP's with (added) terminating "|;"
if ( $string =~ /$OPregex/ ) {
print "\$OPRegex matches: $1 and $2";
} else {
print "no match in \$OPRegex";
}
####
perl F:\_wo\pl_test\735593.pl
$regex matches: 1 and a.gif
no match in $OPRegex