Special_K has asked for the wisdom of the Perl Monks concerning the following question:
I have the following perl script:
#!/usr/bin/perl -w use strict; use Getopt::Long; my $string; GetOptions( "string=s" => \$string ); printf("string = $string\n");
I have the following shell script that calls the above perl script:
#!/bin/tcsh /home/perl_scripts/pass_newline_as_text.pl \ -string 'foo\nbar'
The output I would like to see is as follows:
string = foo bar
The actual output I'm seeing is the following:
string = foo\nbar
Is there a way to have the '\n' interpreted as an actual newline character by the perl script? I've tried enclosing the string in single and double quotes, and using 1-3 backslash escapes on the 'n' character but none of those work.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: passing newline in string argument
by haukex (Archbishop) on Aug 01, 2025 at 19:14 UTC | |
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 | |
| |
Re: passing newline in string argument
by ikegami (Patriarch) on Aug 02, 2025 at 00:02 UTC | |
by haukex (Archbishop) on Aug 02, 2025 at 08:40 UTC | |
Re: passing newline in string argument
by NetWallah (Canon) on Aug 02, 2025 at 02:45 UTC | |
by haukex (Archbishop) on Aug 02, 2025 at 08:42 UTC | |
by eyepopslikeamosquito (Archbishop) on Aug 02, 2025 at 10:41 UTC |