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

2006-09-21 Thread Dave Sherohman
On Thu, Sep 21, 2006 at 01:07:01PM +0700, Welly Hartanto wrote: > Yeah ... Of course more digging for Pearl is absolutely what I need. > I was just so curious because the same algorithm which is "cross-worked" in > java and vc++, but not in my first perl script. The algorithm was fine. The main r

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: Some advice on perl: read byte to hex string

2006-09-20 Thread Welly Hartanto
David Christensen wrote: Welly Hartanto wrote: Below is the perl script ... I see a few mistakes right off the bat, but this is not the proper forum. Take a look here: http://www.elanus.net/book/debugging.html and/or Google for more Perl stuff. If you're still s

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

2006-09-20 Thread David Christensen
Welly Hartanto wrote: > Below is the perl script ... I see a few mistakes right off the bat, but this is not the proper forum. Take a look here: http://www.elanus.net/book/debugging.html and/or Google for more Perl stuff. If you're still stumped, try this newsgroup: comp.lang.perl.mis

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