#!/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 = <STDIN> );
push (my @hexnum, $hexnum);
@hexnum = split ( ' ', $hexnum );
if ( $hexnum eq "" ) {
print "Invalid Input!\n";
print "Press <ENTER> 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 <ENTER> 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 <ENTER> to continue";<>;
}
else {
die "Invalid Input!\n";
print "Press <ENTER> to continue";<>;
}
}
In reply to esn.pl
by defyance
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.