Hi John,

thx, but when i am using it in a script i am getting error, from CLI the same 
input is recognized as numeric and i get proper output. here it is:


i am getting the input value by splitting a string to an array. does split 
function makes the array values character?

$string = a:b:1:2:0x00D70803:0x00FE3490;
@myarr=split(/:/,$string);


my $lpc= join "-", map ord, ( split //, pack "N", $myarr[4] )[ -3 .. -1 ];

this is throwing error:
Argument "0x00D70803" isn't numeric in pack at ./pc.converter.pl line 11.



I also tried to use int() function by specifying    int($myarr[4])  but i still 
get same error.... ??





________________________________
From: John W. Krahn <jwkr...@shaw.ca>
To: Perl Beginners <beginners@perl.org> 
Sent: Monday, January 9, 2012 4:57 PM
Subject: Re: 32 bitx Hex point code to 24 bit (8-8-8) point code

Rajeev Prasad wrote:
> Hello John,
>
> example from SS7 point codes:
>
> input would be: 32 bit hex value like: 0x00FE3453
>
> output expected is 24 bit value (format 8-8-8): 254-52-83


$ perl -le'

my $input = 0x00FE3453;

print join "-", map ord, ( split //, pack "N", $input )[ -3 .. -1 ];
'
254-52-83




John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to