sub dhob2num { my $s = shift; if ($s =~ /^0/) { return oct($s); } # Note: should validate the string return ( 0 + $s ); }