in reply to self-feeding infinite loop

For me, it makes no difference to the actual array whether we do push @array, 'a'; or @array = (@array, 'a');.

That is, irrsepective of which alternative we comment out in the following script, the output is the same:
use strict; use warnings; my @array = ('a'); for (@array) { #push @array,'a'; #alternative 1 @array = (@array, 'a'); #alternative 2 print "@array\n"; sleep(1); # so we can absorb what's happening }
Cheers,
Rob

Replies are listed 'Best First'.
Re^2: self-feeding infinite loop
by chromatic (Archbishop) on Aug 18, 2007 at 21:53 UTC
    That is, irrsepective of which alternative we comment out in the following script, the output is the same:

    Well yeah, that's not the problem. The question is whether Perl iterates over a list pushed onto its stack or pulls from the AV, one element at a time. That is only determinate behavior in so far as it depends on the particular version of Perl you're running, and p5p has claimed free rein to change that in the future as necessary.

    Plus also:

    sleep(1); # so we can absorb what's happening

    ... makes me say "Huh?"