On Mon, 13 Nov 2006 11:35:11 +0530
"Dharshana Eswaran" <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I am working on the code below....
> 
> use strict;
> use warnings;
> 
> my $hex = "43";
> 
> my $binary = unpack 'B*', pack 'H*', $hex;
> 
> print "$binary\n\n";
> 
> my @fields = unpack 'A2A2A4', $binary;
> 
> my $i;
> printf "%-4s => %s\n", $fields[$i++], $_ foreach qw/Ext TypeofNumber
> NumberingPlan/;
> 
> **OUTPUT**
> 
> 01000011
> 
> 01 => Ext
> 00 => TypeofNumber
> 0011 => NumberingPlan
> 
> But, now i have a hash(associative array),
> 
> %TypeofNumber  = ( 00 => Integer, 01 => Floating, 10 => Char, 11 => Double
> );
> 

maybe try something like this?

my %TypeofNumber  = ( 0 => 'Integer', 1 => 'Floating', 16 => 'Char', 17 => 
'Double'
);

print "$TypeofNumber{hex$fields[2]}\n"





Owen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to