perl -e "\$test='a\n\nb'; \$test =~ s/(\\\\\\w)/pack(\"h\",\"\$1\")/ge;print \$test" #### a b