Troubles with special characters in Perl

I´m from Mexico, i want to manipulate strings in Perl which had character "´", for example, i want manipulate word México and convert to Mexico ¿ how can i do that ?
grivera032200Asked:
Who is Participating?
 
sniperrusConnect With a Mentor Commented:
Tr/// is really your best shot, just compile a list of characters to be replaced and the list or replacement characters and execute something like :

$string =~ tr/[é¿]/[e ]/ig;

The elements of the left list are replaced with the corresponding elemnts in the right list. The i and g switches tell the command to make the substitutions on a case insensitive basis (although you are better off providing alternatives in respective cases for this) and to make substitutions globally, i.e. not to stop with only one substitution.
0
 
grivera032200Author Commented:
Adjusted points from 50 to 100
0
 
ozoCommented:
($string = "México") =~ tr/é/e/;
0
 
grivera032200Author Commented:
Thanks for comments,
0
 
ozoCommented:
/ig is invalid syntax for tr
Also, translating [ to [, and ] to ] is not very useful.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.