One thing that might help, depending on which version of perl you are using, is the 'qr' operator. It works similar to qq or qw, except it works on regular expressions, which is very handy for using RegExs as variables passed in from a function or main arg.