#!/usr/bin/perl

# $Id$

$hexstring=uc($ARGV[0]);
if ($hexstring eq "") { die "Please tell me a hex number to convert\n"; }
if ($hexstring !~ /^[01-9A-F]+$/) { die "Please pass a correct hex number\n"; }

my %hdv=();
$hdv{"0"}=0;
$hdv{"1"}=1;
$hdv{"2"}=2;
$hdv{"3"}=3;
$hdv{"4"}=4;
$hdv{"5"}=5;
$hdv{"6"}=6;
$hdv{"7"}=7;
$hdv{"8"}=8;
$hdv{"9"}=9;
$hdv{"A"}=10;
$hdv{"B"}=11;
$hdv{"C"}=12;
$hdv{"D"}=13;
$hdv{"E"}=14;
$hdv{"F"}=15;

$result=0;
$i=0;
while ($i < length($hexstring))
{ 
  $result *= 16;
  $result += $hdv{substr($hexstring,$i,1)};
  $i++;
}
print "$result\n";

