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