When you pass
echo -e \"use\nseveral\nlines\"
to the shell, it passes the following three args to the exec
systems call:
echo
-e
use\nseveral\nlines
How does one create that last string? Here are a few ways:
"use\\nseveral\\nlines" # Escape \W chars in double-quoted strings.
'use\\nseveral\\nlines' # Escape \ and delimiters in single-quoted strings
'use\nseveral\nlines' # ...although it's optional if unambiguous.
The corresponding Perl command would be therefore be
exec('echo', '-e', 'use\nseveral\nlines');
system('echo', '-e', 'use\nseveral\nlines');
open(my $fh, '-|', 'echo', '-e', 'use\nseveral\nlines');
my @output = <$fh>;