#!/usr/bin/perl -w use strict; #Lets convert that ESN print "\n\n", "*" x22, "\n"; print "ESN Converter v.01", "\n"; print "*" x22, "\n"; print "Please enter ESN:"; chomp( my $hexnum = ); push (my @hexnum, $hexnum); @hexnum = split ( ' ', $hexnum ); if ( $hexnum eq "" ) { print "Invalid Input!\n"; print "Press to continue";<>; } else { go(@hexnum); } sub go { if ( length( $hexnum[0] ) == 8 ) { my $mfg = hex( substr( $hexnum, 0, 2 ) ); my $serno = hex( substr( $hexnum, 2, 6 ) ); printf( "\nDecimal: %d %d\nHex: %s\n\n", $mfg, $serno, $hexnum ); print "Press to continue";<>; } elsif ( length( $hexnum[0] ) == 3 ) { printf( "\nDecimal: %3d %8d\n", $hexnum[0], $hexnum[1] ); printf( "Hex: %2X%6X\n\n", $hexnum[0], $hexnum[1] ); print "Press to continue";<>; } else { die "Invalid Input!\n"; print "Press to continue";<>; } }