Another for loop that I would like to know why it does what it does....<br>
<br>
102: $pfile = "/usr/local/test/testfile";<br>
... <br>
434: # make sure a path to $pfile exists.<br>
435: @p = split('/', $pfile);<br>
436: BUILDPATH: for ($d = "/" . shift(@p), $#p > $[, $d .= "/" . shift(@p) ) {<br>
437 next BUILDPATH unless (-d $d); <br>
438: unless (mkdir($d, 0711)) {<br>
439: warn "Cannot create path for bauetc. Cannot save file.";<br>
440: last BUILDPATH;<br>
441 }<br>
442 } # BUILDPATH<br>
<br>
In line 435 @p gets 5 elements "", "usr", "local", "test", "testfile". But the first time I hit line 437 I see this:<br>
<br>
main::saveword(pscript:436): BUILDPATH: for ($d = "/" . shift(@p), $#p > $[, $d .= "/" . shift(@p)) {<br>
DB<1> p join("-", @p)<br>
-usr-local-test-testfile<br>
DB<2> p $#p<br>
4<br>
DB<3> p scalar @p<br>
5<br>
DB<4> s<br>
main::saveword(pscript:437): next BUILDPATH unless (-d $d); <br>
DB<4> p $d<br>
//usr<br>
DB<5> p scalar @p<br>
3<br>
DB<6> <br>
<br>
Why did it shift twice? The initialization step should have shifted once, then the test should have let the loop happen, then AFTER the loop ran through the first time it should have shifted again in the increment step. But it looks to me like it is jumping straight from initialize to increment, and then to the loop.<br>
<br>
What am I overlooking?<br>
<br>
Thanks again,<br>
- Kai.<br>
<br>
<br>
<br>
<br>
102: $pfile = "/usr/local/test/testfile";<br>
... <br>
434: # make sure a path to $pfile exists.<br>
435: @p = split('/', $pfile);<br>
436: BUILDPATH: for ($d = "/" . shift(@p), $#p > $[, $d .= "/" . shift(@p) ) {<br>
437 next BUILDPATH unless (-d $d); <br>
438: unless (mkdir($d, 0711)) {<br>
439: warn "Cannot create path for bauetc. Cannot save file.";<br>
440: last BUILDPATH;<br>
441 }<br>
442 } # BUILDPATH<br>
<br>
In line 435 @p gets 5 elements "", "usr", "local", "test", "testfile". But the first time I hit line 437 I see this:<br>
<br>
main::saveword(pscript:436): BUILDPATH: for ($d = "/" . shift(@p), $#p > $[, $d .= "/" . shift(@p)) {<br>
DB<1> p join("-", @p)<br>
-usr-local-test-testfile<br>
DB<2> p $#p<br>
4<br>
DB<3> p scalar @p<br>
5<br>
DB<4> s<br>
main::saveword(pscript:437): next BUILDPATH unless (-d $d); <br>
DB<4> p $d<br>
//usr<br>
DB<5> p scalar @p<br>
3<br>
DB<6> <br>
<br>
Why did it shift twice? The initialization step should have shifted once, then the test should have let the loop happen, then AFTER the loop ran through the first time it should have shifted again in the increment step. But it looks to me like it is jumping straight from initialize to increment, and then to the loop.<br>
<br>
What am I overlooking?<br>
<br>
Thanks again,<br>
- Kai.<br>
<br>
<br>
<br>