Hello,
I am trying to convert 32 bitx Hex point code to 24 bit (8-8-8) point code. i tried to use below script from net, but due to limited understanding of perl and above script, I was not able to resolve my problem. Can someone please help me resolve my issue? thank you. Rajeev #!/usr/bin/perl -w my $decimalcode = shift; my $binarycode = 0b0; my @ciscocode ; $binarycode = unpack(”B32″,pack(”N”,$decimalcode)); my @itucode = grep {$_ ne ”} split(/(\d{18})(\d{3})(\d{8})(\d{3})/,$binarycode); my @ansicode = grep {$_ ne ”} split(/(\d{8})(\d{8})(\d{8})(\d{8})/,$binarycode); print “itucode = $itucode[1] $itucode[2] $itucode[3]\n”; print “ansicode = $ansicode[1] $ansicode[2] $ansicode[3]\n”; my $bintest = unpack(”N”,pack(”B32″,substr(”0″ x 32 . $binarycode, -32))); printf (”Decimal Code = [%05d]\n”,$bintest); @ciscocode = (unpack(”N”,pack(”B32″,substr(”0″ x 32 . $itucode[1], -32))), unpack(”N”,pack(”B32″,substr(”0″ x 32 . $itucode[2], -32))), unpack(”N”,pack(”B32″,substr(”0″ x 32 . $itucode[3], -32)))); printf (”ITU Cisco Code = %03d-%03d-%03d\n”, $ciscocode[0],$ciscocode[1],$ciscocode[2]); @ciscocode = (unpack(”N”,pack(”B32″,substr(”0″ x 32 . $ansicode[1], -32))), unpack(”N”,pack(”B32″,substr(”0″ x 32 . $ansicode[2], -32))), unpack(”N”,pack(”B32″,substr(”0″ x 32 . $ansicode[3], -32)))); printf (”ANSI Cisco Codec = %03d-%03d-%03d\n”, $ciscocode[0],$ciscocode[1],$ciscocode[2]); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/