All pastes #293678 Raw Edit

Untitled

public text v1 · immutable
#293678 ·published 2006-12-27 20:11 UTC
rendered paste body
use Encode qw/encode decode/; 
$_ = ascii_to_hex('frozen is jew');
$_ = hex_to_ascii($_);
print $_;
sub ascii_to_hex ($)
{
	(my $str = shift) =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg;
	$str =~ s/(..)/\\x$1/g;
	return $str;
}
sub hex_to_ascii ($)
{
	(my $str = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
	$str =~ s/\\x//g;
	return $str;
}