sub t2h()
{
print "Type something to convert from ascii to Hex.";
print " Cuts off after one line.\n";
print unpack("h*", <>),"\n";
}
sub h2t()
{
print "Type something to convert from Hex to ascii.";
print " Cuts off after EOF (Control-D).\n";
print pack("h*",<>),"\n";
}
while (1)
{
print <<EOF;
Welcome to the stupid-perl-crap.
What do you want to do?
1. Convert from Ascii Hex to Text
2. Convert from Text to Ascii Hex
3. Quit
EOF
$_ = <STDIN>;
exit if /3/;
t2h() if /2/;
h2t() if /1/;
}
It goes to these functions, but only one of them works, and that's t2h. It prints out some hex (including newline, not what I want). That same hex doesn't work through the inverse function.
Pi |