Robert Citek wrote:
How does one transliterate in perl using a negated character class?
For example, I have a string abcxyz and I would like to turn it into
abNNNz. I've been able to do the following:
$ echo "abcxyz" | perl -plane '$_ =~ y/[abz]/N/ '
NNcxyN
so I figured negating would give me the negated set, but it doesn't:
$ echo "abcxyz" | perl -plane '$_ =~ y/[^abz]/N/ '
NNcxyN
I know I've done this before. What am I overlooking?
echo "abcxyz" | perl -ple '$_ =~ tr/abz/N/c'
See `perldoc perlop` and search for /tr\/SEARCHLIST\/REPLACEMENTLIST\/cds/
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/