in reply to Regex to trim non Ascii characters
You're calling the sub like so: $x = translate($x). But what does your subroutine return?
Remember that my $x creates a fresh new variable. Operating on a local copy inside the subroutine does not change its arguments. Either you work on the passed value itself
or return the working copysub mutate { for (shift) { s/./x/g; } }
sub translate { my $x = shift; $x =~ s/./x/g; return $x; }
As for the ASCII, all the printable characters fall in a short range, so a simple tr/\040-\176//cd ought to do.
|
|---|