#!/usr/bin/perl -w
use strict;

my $param = shift;

if (!$param) {
	$param = <STDIN>;
}
elsif ($param eq '-h') {
	print "usage: b2decode [-h] [ipadress]\nif ipadress is not supplied it will be read from stdin\n";
	exit;
}

my $addr = '';
my $out = '';

($addr) = $param =~ /-.*?-.*?-.*?(.*?)\.cust/i;
for (my $n = 0; $n < length($addr); $n+=2) {
	my $c = substr($addr, $n, 2);
	if (length($c) < 2) {
		$out .= $c;
	}
	else {
		my $d = hex($c);
		if ($d < ord('a')) {
			$d = $c;
		}
		else {
			$d = sprintf("%c", $d);
		}

		$out .= $d;
	}
}

print "$out\n";
