This is my first entry into CUFP, but I thought this was pretty cool, so I thought I'd go for it.

I'm not sure how many, if any, of you work with wireless phones, or are employed by a wireless company, but if you are out there, you may find this cool. An ESN (Electronic Serial Number) comes in three different formats, Decimal, Hex, and Oct. Well, my company runs two different types of switches, Lucent and Nortel. Nortel uses Decimal ESNs, which are the most commonly used, Lucent on the other hand uses Hex, so we have to have a converter handy to do the math and give us both versions. I have seen an ESN converter in C and in JAVA, but I have never seen one in Perl. So, in good old-fashioned experimentation, I came up with this. It is a simple converter, and a simple script, but it does the job beautifully. Let me know what you think!

UPDATE:I reworked script to work with -w. Look at my home node Scratchpad for the code.
#!/usr/bin/perl use strict; my $hexnum= '00000000'; my $hexnum= $ARGV[0]; my $mfg=hex(substr($hexnum,0,2)); my $serno=hex(substr($hexnum,2,6)); if(length($hexnum) < 8) { &dec } else { printf("\nDecimal: %d %d\nHex: %s\n\n",$mfg,$serno,$hexnum); +} sub dec { my $decmfg= '00'; my $decserno= '00000000'; my $decmfg= $ARGV[0]; my $decserno= $ARGV[1]; if(length($decmfg) < 3) {printf("Syntax:\n\Dec 000 00000000\nHex 000 +00000\n")} else { printf("\nDecimal: %3d %8d\n",$decmfg,$decserno); printf("Hex: %2X%6X\n\n",$decmfg,$decserno); } }


-- Yes, I am a criminal. My crime is that of curiosity.