cmd - Cannot include space in string in one line program mode for Perl on Windows? -
the command
perl -ne "print "" """ anytextfile.txt
running on windows latest activeperl installed (5.020) complains can't find string terminator '"' anywhere before eof @ -e line 1.
. other characters or variables work expected, like
perl -ne "print ""$.-$_""" anytextfile.txt
i checked double quotes passed perl expected, if little weird when escape double quotes in cmd.exe. why space cannot shown in above double quoted string? using single quote work loses variables interpolation functionality.
perl -ne "print \" \"" anytextfile.txt
why?
a lot of programs arguments means of standard argument parser used c library used compile language itself, libraries or used base.
for windows, in general, "rules" argument parsing
arguments delimited white space, either space or tab.
a string surrounded double quotation marks interpreted single argument, regardless of white space contained within. quoted string can embedded in argument. note caret (^) not recognized escape character or delimiter.
a double quotation mark preceded backslash, \", interpreted literal double quotation mark (").
backslashes interpreted literally, unless precede double quotation mark.
if number of backslashes followed double quotation mark, 1 backslash () placed in argv array every pair of backslashes (\), , double quotation mark (") interpreted string delimiter.
if odd number of backslashes followed double quotation mark, 1 backslash () placed in argv array every pair of backslashes (\) , double quotation mark interpreted escape sequence remaining backslash, causing literal double quotation mark (") placed in argv.
Comments
Post a Comment