You're not escaping or quoting your quotes.
The literal string " awk -F"
begins with a double quote and last only until it sees another un-escaped double quote. So it's done at F"
. If you put a =
after that then it's entirely a different token. You are assigning.
The reason that the error message says what it says is that assignment goes from right to left. Look further down your line and you'll see
"...OFS="=" /var/tmp/file "
That's the assignment it starts with. Then it looks leftward and sees that you are assigning it to an assignment. And gives you the error you're getting.
Perl will let you put double quotes in a interpolated string (one that allows the "stringification" of variables) which normally are delineated by double quotes. But you need to use qq
:
Look closely at the coloring between the two lines:
system(" awk -F" = " '{s[$1]++}{print $1s[$1],$2}' OFS=" = " /var/tmp/file " );
system( qq(awk -F"=" '{s[$1]++}{print $1s[$1],$2}' OFS="=" /var/tmp/file));
Look very closely at the first line, notice that the rest of the string is reddish while the equals are black. It's jumped out of the string and you're dealing with =
as a new token.
Now, SO highlighting doesn't deal too well with all of Perl's ability, so the qq(
operator isn't highlighted correctly. But if you ignore that, you'll see that all the stuff in quotes shows up as in quotes. And if you trust that qq
can do the job of passing it all as a string, then you'll trust that it's all the SAME grammatical unit.