Permalink
Browse files

Add hex-dec.pl

  • Loading branch information...
1 parent 1b30bcf commit bc348ef46cd0e302ef25af742fe73c95f15e06d1 @dbb committed Jun 1, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 hex-dec.pl
View
@@ -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.