Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl, using tr function to convert uppercase to lowercase and vice-versa at the same time?

I have a string

$string= 'AbCdEf';

and I want to use the tr function to convert all the uppercase letters to lower case and all the lower case to upper case.... at the same time. I basically just want to reverse it to become.

aBcDeF

I came up with this line, but I'm not sure how to modify it to do what I want. Any help please?

$string=~ tr/A-Z/a-z/;

Thanks!

like image 657
Brian Avatar asked Apr 09 '11 21:04

Brian


1 Answers

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

like image 121
friedo Avatar answered Oct 28 '22 18:10

friedo