perl - Why is '\t', returned from "backtick" call, expanded to tabulator? What all characters are expanded? -
if run simple perl script (on linux, bash),
$to_run = q(echo '\t'); $res = `$to_run`; print $res i expect \t printed - is, backslash character , "t" character. indeed, if run in bash
echo '\t' i see \t. however, perl script prints tabulator.
why tabulator expanded in $res? characters expanded that? and, importantly, how stop expanding?
backticks evaluated using /bin/sh, regardless of whatever shell may want use, , it's posix xsi-conformant version of echo implemented sh that's converting \t tab. try out running echo '\t' inside sh.
for avoiding behavior, trying using printf '%s\n' instead of echo in backticks.
Comments
Post a Comment