sub validate_text { my ($text) = @_; if ($text =~ s/[^A-Za-z0-9 -]+//g) { print "Funny business fixed\n"; } else { print "Text was already clean\n"; } return $text; } my $validated = validate_text($test1);