If the parameters "g" and "s" are not really needed for your task, and you really want to compare only matching substrings, you can do a one-line test as follows:
if (($a =~ /regex1/)[0] == ($b =~ regex2/)[0]) { ...
And if you need to know which two lines matched, just add temporary variables to hold them:
if (($first = ($a =~ /regex1/)[0]) == ($second = ($b =~ regex2/)[0])) { ...
But if you really want to compare all consecutive matches on each line to make sure that each pair is the same, there is no solution with a single expression that I can think of doing it. Your regular expressions return a list, and "==" compares their lengths. You should use the first solution suggested above and write the comparison code in "long-hand".
The second solution above will not work, as it will only check the first match on each line.
It’s a little difficult to understand what you are trying to do, but you could at least discard the “i” option in the first test for / (\ d +) /. Presumably, the s parameter is only needed for the second line, as you are looking for inline newlines.
Voldehnuit
source share