<?xml version="1.0" encoding="windows-1252"?>
<node id="1017906" title="Re^3: perl onliner on multiple files" created="2013-02-08 18:54:18" updated="2013-02-08 18:54:18">
<type id="11">
note</type>
<author id="805072">
7stud</author>
<data>
<field name="doctext">
In a bash shell, I get:
&lt;code&gt;

$ perl -nE "/: / and $c += (split/: /)[0]; if( eof(ARGV) ){ say qq[SUM.$ARGV =$c]; $c=0 }" tmp_*
syntax error at -e line 1, near "+="
syntax error at -e line 1, near "; ="
Execution of -e aborted due to compilation errors.
&lt;/code&gt;
&lt;p&gt;And:&lt;/p&gt;
&lt;code&gt;
$ c=10
$ echo c
c
$ echo $c
10
$ echo "The total is: $c"
The total is: 10
$ echo 'The total is: $c'
The total is: $c
&lt;/code&gt;So within double quotes, the shell expands $variables, which of course happens *before* the shell hands the text over to the perl command.  That is similar to the way the shell expands your glob: tmp_* and replaces it with a list of file names, which is what the perl command ends up seeing.
</field>
<field name="root_node">
1017880</field>
<field name="parent_node">
1017889</field>
</data>
</node>
