Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

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 ?
0
grivera032200
Asked:
grivera032200
  • 2
  • 2
1 Solution
 
grivera032200Author Commented:
Adjusted points from 50 to 100
0
 
ozoCommented:
($string = "México") =~ tr/é/e/;
0
 
sniperrusCommented:
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:
Thanks for comments,
0
 
ozoCommented:
/ig is invalid syntax for tr
Also, translating [ to [, and ] to ] is not very useful.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now