In addition to the other suggestions, I would add that you want to compile the RegEx only once, since they appear to be unchanging, at least during the execution of the script.
This can be done with either the
/o
modifier, which tells Perl to compile the regex only once. And potentially use with the
qr
"
quote regex" (
perlop#Regexp-Quote-Like-Operators).