This seems like a shell issue instead of a Perl question, because it appears the shell isn't interpreting \n as a newline. In other words, Perl is getting passed the literal 8-character string "foo\\nbar" from the shell.
I'm unfortunately not well-versed in tcsh so the "best" solution I've found so far is:
#!/bin/tcsh /home/perl_scripts/pass_newline_as_text.pl \ -string "foo\ bar"
I would typically recommend against working around this in Perl, because if you start supporting "\\n" to "\n" translation in Perl, then the question is which escape codes do you want or need to support, and it quickly becomes overly complicated - see my three posts in this thread: Can't get \n or other character/translation escapes to interpolate if originally read from a data file
In reply to Re: passing newline in string argument
by haukex
in thread passing newline in string argument
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |