my @buffer = (0) x 5; my $pointer = 0; for (0..30) { print "old value: ", $buffer[$pointer], "\n"; print "new value: $_\n"; $buffer[$pointer] = $_; $pointer = (++$pointer) % @buffer; }
In reply to Re^2: Circular buffer
by mellon85
in thread Circular buffer
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |