http://qs321.pair.com?node_id=634964


in reply to Scrubbing a string

Use regexes with char classes:

#!/usr/bin/perl use warnings; use strict; my $allowed = "pure"; my $re = quotemeta $allowed; my $str = "p u+r-e"; $str =~ s/[^$re]//g; print $str, "\n";