I am searching for a string in Perl and storing it in another scalar variable. I want to print this scalar variable. The code below doesn\'t seem to work. I am not sure what is
The regex matching operation returns true (1) for match success, false otherwise. If you want to retrieve the match, you should try one of the following:
($m1, $m2) = $string =~ /$regex/
Note that you need to use captures in your regex for these to work. Which you're not doing yet.
You ought to take a look at the complete documentation in perlop, section "Regexp Quote-Like Operators"