in reply to empty hits with regex
You have two captures in the regex so for each match you get two entries added to @hits. However one of the captures will be undef because only one of the captures will match. Instead you could:
print '|', join ('|, ', "caaat" =~ m/( (?<=c)a | (?<=k)t )/gx), "|\n";
Prints:
|a|
Note that if you are using strictures (use strict; use warnings;) you will have received a 'Use of uninitialized value ...' warning.
|
|---|