in reply to Reading hex data

Find the relevant text using a regular expression, then go through it two characters at a time and use hex() and chr() to decode (added a closing 00020400 to your data):
my $raw = join '', <DATA>; $raw =~ s/\n//g; if(my($encoded) = ($raw =~ /0002000000(.*?)00020400/)) { while($encoded =~ /(..)/g) { print chr (hex($1)), "\n"; } } __DATA__ 045a010000020000004c45534f4e 4452412043414c4c454420424143 4b2c204920414456495345442054 48415420574500020400
cracks your 'code':
L E S O N D R A C A L L E D B A C K ,

Replies are listed 'Best First'.
Re^2: Reading hex data
by fishbot_v2 (Chaplain) on Aug 09, 2005 at 02:21 UTC

    The same, but with an unpack:

    my $raw = do { local $/; <DATA> }; # inline slurp $raw =~ s/\s//g; print map { chr hex } unpack '(A2)*', $1 if $raw =~ m/0002000000(.*?)00020400/;

    Perhaps a bit too idiomatic, but I prefer using unpack to split characters into fixed widths. It is a tiny bit faster, though not blazingly so:

    Rate regex unpack regex 953336/s -- -38% unpack 1549170/s 62% --