Skip to content

Commit

Permalink
Add hex-dec.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
dbb committed Jun 1, 2012
1 parent 1b30bcf commit bc348ef
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hex-dec.pl
@@ -0,0 +1,17 @@
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;

for ( @ARGV ) {
my $sum;
my @digits = reverse( split "", $_ );
for ( my $i=0; $i<=$#digits; $i++) {
my $hex= hex($digits[$i]);
say "$digits[$i] to the $i";
$sum += $hex * 16 ** $i;

}
say "sum = $sum";
}

0 comments on commit bc348ef

Please sign in to comment.