sub untaintMe { my ($self, $inputArg, $typeArg) = @_; my ($temp, $reason); my @returnArray; if ($typeArg eq 'path') { $inputArg =~ /[\/\w\-._]+/; # includes 'file' chars + "\" $temp = $&; $reason = $` . '...' . $'; # create the reason code } if ($reason eq '...') # no mismatches found if ($temp ne '') { @returnArray = ($temp, ""); } else { @returnArray = ('', "invalid input, not enough characters to match $typeArg pattern"); } } else { @returnArray = ('', "invalid input, string contains $reason"); } return @returnArray; }