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

2006-09-21 Thread Mumia W..
On 09/21/2006 12:06 AM, Welly Hartanto wrote: Thank you for all your suggestions. It's solved by using : for ($i=0; $i < (length($gotit)); $i++) { my $c = substr($gotit, $i, 1); $str1 = sprintf("%01x", ((ord($c) & 0xf0) >> 4) & 0x0f); $str2 = sprintf("%01x", ord($c) & 0x0f); prin

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

2006-09-20 Thread Welly Hartanto
Dave Carrigan wrote: On Tuesday 19 September 2006 23:29, Welly Hartanto wrote: for ($i=0; $i < (length($gotit)); $i++) { my $c = substr($gotit, $i, 1); $c1 = $c & 0xF0; #get the high nibble $c1 = $c1 >> 4; # $c1 =

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

2006-09-20 Thread Mumia W.
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 i

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

2006-09-20 Thread Mumia W..
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 i

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

2006-09-20 Thread Dave Sherohman
On Wed, Sep 20, 2006 at 01:29:44PM +0700, Welly Hartanto wrote: > #Loop through the whole data > for ($i=0; $i < (length($gotit)); $i++) { > my $c = substr($gotit, $i, 1); > $c1 = $c & 0xF0; #get the high nibble > $c1 = $c1 >> 4; # >

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

2006-09-20 Thread Dave Carrigan
On Tuesday 19 September 2006 23:29, Welly Hartanto wrote: > for ($i=0; $i < (length($gotit)); $i++) { > my $c = substr($gotit, $i, 1); > $c1 = $c & 0xF0; #get the high nibble > $c1 = $c1 >> 4; # > $c1 = $c1 & 0x0F;

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

2006-09-20 Thread Michael Marsh
On 9/20/06, Welly Hartanto <[EMAIL PROTECTED]> 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 conv

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

2006-09-19 Thread Welly Hartanto
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. Below