$mystring = pack('H*', '0D0A...'); #### # Ignores whitespace ($mystring = '0D 0A ...') =~ s/([0-9a-fA-F]{2})/chr($1)/g; #### # Multiline and ignores whitespace ($mystring = <<'__EOI__') =~ s/([0-9a-fA-F]{2})/chr($1)/g; 0D 0A ... 0D 0A ... 0D 0A ... ... __EOI__