Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add hex-dec.pl

  • Loading branch information...
commit bc348ef46cd0e302ef25af742fe73c95f15e06d1 1 parent 1b30bcf
@dbb authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 hex-dec.pl
View
17 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";
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.