in reply to Use of uninitialized value in pattern match (m//)

If the 'undefined' warning bothers you you can fix it by making sure $tmp2 is always defined. This works wonders:
my $tmp2 = ""; $tmp2 = $2;
...which gives you the added bonus of scoping $tmp2. Plus, you don't have to check whether a character is present in your var before substituting it out.
if($tmp2 =~ m/\'/) { $tmp2 =~ s/\'/\\\'/g; # escape the single quotes.. }
is better written as:
$tmp2 =~ s/'/\\'/g; # escape the single quotes..
If there's a single quote in $tmp2 it'll get escaped. Otherwise nothing happens. Note that you don't have to escape single-quotes within a regex.

Lastly if you're paranoid about non-Alphanumerics in your regex's check out the \Q modifier. This does what you want automatically within a regular expression without you having to do anything else.

Gary Blackburn
Trained Killer

Edited:Added my $tmp2=""; to really make $tmp2 defined. :-P