At 04:22 PM 8/6/2001 -0200, Hamish Whittal wrote:
>Hi all,
>
>I am using Joe Marzot's perl module 4.2.0. I am doing a walk of a
>variable that returns a hex value. Problem is, I have no idea the value
>will be hex, till I try to print it. 2 questions:
>
>1. I think I could find a hex value by testing the returned value
>against a regex. Yes/No

Yes.
if ($name =~/\x07/){
## do something.. note you need the \ before the x
}

>2. I want to be able to translate the hex value to something printable,
>although I am not sure I am getting 07 D0 for example. All I can see is
>the upprintable blurb on the screen.

If you know you have x07 (CTRL/G) you can do a translate to whatever hex 
value or pre-determined character you want

$name= "\x33";          # Shows the number 3 (x07 is  CTRL G which doesn't 
show anything)

print "Name is $name \n";
$name =~ tr/\x33/\x4B/;         # can also replace \x4B with any other 
character you want, it will still work
                                   (i.e.: $name =~ tr/\x33/J/;   # shows J
print "Name is now $name\n";    # shows the letter K (lowercase k is x6B)

You can also use [] to get range of hex values (ie. [\x00 - \x1F]) you may 
want to translate or delete.

HTH


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

Reply via email to