in reply to Converting decimal value to hex

For your actual problem:
Did you tried a simple:
$name =~ s/\s+$//;

which should do the trick.

For your display problem:
In general you can use pack/unpack for conversions.
Here I would just use:

use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $name;

which would print $VAR1 = "12345\t\n"; in your example.