in reply to passing newline in string argument
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: passing newline in string argument
by ysth (Canon) on Aug 01, 2025 at 21:43 UTC | |
by jaredor (Priest) on Aug 01, 2025 at 22:49 UTC | |
by ikegami (Patriarch) on Aug 02, 2025 at 00:16 UTC | |
by jaredor (Priest) on Aug 02, 2025 at 05:05 UTC | |
by ikegami (Patriarch) on Aug 02, 2025 at 18:27 UTC |