in reply to Regex: return the pattern instead of the actual match
You can't, and it doesn't make much sense to do so. Maybe you want something like this:
my $matched_pattern; if (/$regex/) { $matched_pattern = $regex; };
If you're really bent on filling $1 with an arbitrary string, you can do so by doing:
my $regex = qr/foo/; $regex =~ /^(.+)$/ms; # fill $1 with $regex print $1;
This does not make sense to me, so most likely I misunderstood your question. If you want something else, please tell us the output you want.
|
|---|