in reply to Re^2: uppercase/lowercase in a single expression
in thread uppercase/lowercase in a single expression

Well, that's exactly what tr does.

Example:

perl -le '$line1 = "asdadAADSAsdfsfASASDjljsdASDAS"; $line1 =~ tr/[A-Z +a-z]/[a-zA-Z]/;print $line1;'
Prints:
ASDADaadsaSDFSFasasdJLJSDasdas

Replies are listed 'Best First'.
Re^4: uppercase/lowercase in a single expression
by davido (Cardinal) on Sep 07, 2006 at 07:10 UTC

    Transliteration doesn't use character classes. You don't need [ and ], unless you actually intend to also transliterate those square bracket characters. What's needed is:

    $line1 =~ tr/A-Za-z/a-zA-Z/

    ...assuming you're not dealing with some funky character set.


    Dave

      Ah, thanks for the correction. As I mentioned above, I've rarely used tr before, so it's not surprising that I got the example wrong :)