On Aug 23, Carl W Rogers said:

>I don't know if this is possible... But I'm trying to replace the high-hex 
>symbol for one-half (\xBD) with 1/2

No, you have to use a substitution (s///) for that.  tr/// is for
character-to-character translations.

>$variable =~ tr/[\xBD]/"1/2"/;                 #tr doesn't like this, so I tried...

Fails because of the / in "1/2".  You'd have to backslash it, but that
doesn't make the tr/// do what you expect.  Leave out the [...] in the
left-hand side of the tr///, because a tr/// is already using character
classes.

>$replacement = "1/2";
>$variable =~ tr/[\xBD]/$replacement/;          #tr replaces \xBD with 'r', then I 
>tried

Fails because tr/// does not interpolate variables.

>$variable =~ tr/[\xBD]/\$replacement/; # just to see if the \ in front of 
>the $ would work.. It didn't

Fails as well.

You want:

  s{\xBD}{1/2}g;

Plain and simple:  "find hex character BD, and replace it with '1/2'".

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to