<?xml version="1.0" encoding="windows-1252"?>
<node id="85347" title="For loop problem" created="2001-06-03 18:24:29" updated="2005-07-19 14:08:39">
<type id="115">
perlquestion</type>
<author id="77754">
srawls</author>
<data>
<field name="doctext">
I was working on some obfuscated code, and came across a problem.  Well, first what I was trying to do was to do something 12 times (i.e. for(1 .. 12)).  I tried this:
&lt;code&gt;
for(++$....$.++.$.)
{print "$_\n"}
&lt;/code&gt;
And to my surprise it printed 2 through 12.  Before I move on, I'll explain what I think should happen.  To do this, I'll clean up the formatting a bit:
&lt;code&gt;
for(++$. .. $.++ . $.) #note before I had used ... instead of ..
&lt;/code&gt;
Now, let's examine those values:
&lt;code&gt;
++$.      = 1 
$.++ . $. = 12 #the concatenation of 1 and 2.
&lt;/code&gt;
So, I tried to take it apart and see which individual element was causing the problem, and eventually I came up with this:
&lt;code&gt;
for(++$....$..$.) #note took out the second ++
&lt;/code&gt;
Now it prints 1 through 11, exactly what I expect.  What I think is happening is that the second ++ is effecting the value of &lt;code&gt;$.&lt;/code&gt; somehow, before it's supposed to.  
&lt;p&gt;
This is really baffaling me, so any help is appreciated,
&lt;br&gt;thanks
&lt;BR&gt;&lt;BR&gt;The 15 year old, freshman programmer,&lt;BR&gt;
Stephen Rawls</field>
</data>
</node>
