in reply to Re: Regex tester
in thread Regex tester

There are a few things here that could use a little tidying. First off, the mandatory mantra: Always use strictures (use strict; use warnings; - see The strictures, according to Seuss).

Of more immediate benefit: if you find you need to include double quote character in a string use qq for quoting instead of " (see perlop's Quote and Quote-like Operators). For example your print statements become:

print qq{Matched: "$&"\n}; # print match print qq~Before match: "$`"\n~; # print data before match print qq|After match: "$'"\n|; # print data after match

although you may wish to use a here-doc instead (look for here-doc in the same docs mentioned above):

print <<STUFF; Matched: "$&" Before match: "$`" After match: "$'" STUFF

Perl reduces RSI - it saves typing