in reply to Return Question in Subroutine

Somewhat OT; in general, I find it easier to specify which characters to allow, rather than trying to anticipate what might be used against me.

print cleanup(q/!s@#cr%ipt^&script?M:r;"._ \'W\\][iz][{}=a=+-r-d`~\''/ +); sub cleanup { my $string = shift; if ( defined $string ){ $string =~ s/[^\p{Alnum}., ]//g; $string =~ s/script//g; } return $string; }