BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
Update: Damn it! Never mind; the penny dropped. It's the same order of evaluation thing there's been a couple of recent threads about: $d[ $pB-1 ] = $d[ $pB++ ]
There's no guarantee that $pB-1 will be evaluated before $pB++; even though the post increment guarantees that the preincrement value will be used for the second subscript.
Why is this:
my $pB; for( $pB = $topB+1; $pB < $topC && $d[ $pB ] < $temp; $d[ $pB-1 ] = $d +[ $pB++ ] ) { };
Not equivalent to this?
my $pB; for( $pB = $topB+1; $pB < $topC && $d[ $pB ] < $temp; $d[ $pB-1 ] = $d +[ $pB ], $pB++ ) { };
|
|---|