>>>>> "RC" == Robert Citek <robert.ci...@gmail.com> writes:

  RC> On Fri, Sep 25, 2009 at 5:46 AM, Shawn H Corey <shawnhco...@gmail.com> 
wrote:
  >> Robert Citek wrote:
  >>> 
  >>> How does one transliterate in perl using a negated character class?
  >> 
  >> echo "abcxyz" | perl -ple '$_ =~ tr/abz/N/c'
  >> 
  >> See `perldoc perlop` and search for /tr\/SEARCHLIST\/REPLACEMENTLIST\/cds/

  RC> Thanks.  I took a little break from coding which helped clear my mind.
  RC>  That and your reference to the right doc section (instead of an
  RC> overly vague RTFM) reminded me that I wanted s/// not y///.

  RC> $ echo "abcxyz" | perl -ple '$_ =~ s/[^abz]/N/g'

that works but tr/// is faster and more direct. regexes are slower than
simple char translation by a table.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to