in reply to Re^4: Filtering unwanted chars from input fieldin thread Filtering unwanted chars from input field
The left hand side of the tr is not a regular expression. Just include a real space in the character list.
$ perl -E ' > @data = ( > q{Hello, world!}, > q{te-st%$/*.}, > q{All_of_this_is_OK.}, > q{!@#$%^&*()12345}, > ); > say for map { tr{A-Za-z0-9_. -}{}cd; $_ } @data;' Hello world te-st. All_of_this_is_OK. 12345 $ [download]
Cheers,
JohnGG