[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Some advice on perl: read byte to hex string



On 09/20/2006 01:29 AM, Welly Hartanto wrote:
I've managed to create an application for reading some bytes of data
from an id card reader connected into a serial port.
But it's under Win$ ...
So, now I've been trying for at least capturing the data then convert
it the way I want.
The convertion is called "byte to hex string" convertion.
[...]

Read "perldoc -f pack"; it's easy to convert hex strings in perl:

    my $gotit = 'Every good boy does fine.';
    my $hex = unpack('H*', $gotit);
    print $hex, "\n";
    my @hex = map "0x$_", $hex =~ m/../g;
    print "@hex\n";

I hope this helps.


--
paduille.4058.mumia.w@earthlink.net



Reply to: