my $arg = "10FFFF"; # for instance # simpler way? eval { use warnings FATAL => qw(all); my ($fh, $string); open($fh, ">", \$string) || die "open(string) failed: $!"; binmode($fh, ":utf8"); print $fh chr(hex("$arg")); }; die "good, caught it from eval: $@" if $@; # don't want to get here binmode(STDOUT, ":utf8"); print chr(hex($arg));