Rob,

my @fields = unpack '(A7)*', $binary;

When i tried compiling, it says that

"Invalid type in unpack: '(' at line 10."

It does not accept this, i tried other combinations too. But it does not
compile the program.

What should i do?

Thanks and Regards,
Dharshana


On 11/16/06, Rob Dixon <[EMAIL PROTECTED]> wrote:

Dharshana Eswaran wrote:
> Hi all,
>
> I am working on the code below:
>
> use strict;
> use warnings;
>
> my %TypeofNumber = (
>  '00' => Integer,
>  '01' => Floating,
>  '10' => Char,
>  '11' => Double );
>
>
> my @hex = ("14", "2a", "11", "83");
> $hex_length = @hex;
>
> for($i=0; $i<$hex_length; $i++) {
>
> my $binary = unpack 'B*', pack 'H*', $hex[$i];
>
> print "$binary\n\n";
>
> my @fields = unpack 'A2A2A4', $binary;
>
> my $i;
> printf "%-4s => %s\n\n", $fields[0], 'Ext';
>
> print "TypeofNumber\n";
> printf "%-4s => %s\n\n", $fields[1], $TypeofNumber{$fields[1]};
>
> printf "%-4s => %s\n\n", $fields[2], 'NumberingPlan';
>
> }
>
> Now i need to split the binary value of the first element into two
halves
> (A7A1), seecond element into A6A2, third element into A5A3 and so on...
>
> Then i need to display the 7bits of the first element, then join 1bit of
> the
> first element to the 6bits of the second element(that is join A1 of
first
> element and A6of the second element) and then display it, then join A2
of
> the second element and A5 of the third element and then display it and
so
> on.
>
> How to go bout this?

Does this help?

Rob


use strict;
use warnings;

my @hex = ("14", "2a", "11", "83");
my $hex = join '', @hex;
my $binary = unpack 'B*', pack 'H*', $hex;

my @fields = unpack '(A7)*', $binary;
print $_, "\n" foreach @fields;

**OUTPUT

0001010
0001010
1000010
0011000
0011

Reply via email to