use Devel::Peek; my @a = 1..2; for (my $i = 0; 1; $i++) { print "Stats for $i\n"; Dump(\@a); ; push @a, shift @a; } #### use strict; use IPC::Open3; my $array_size = shift || 2; my $code = <<'CODE'; use Devel::Peek; my @a = 1..COUNT; for (my $i = 0; 1; $i++) { print STDERR "Iteration=$i\n"; Dump(\@a); print STDERR "\nITERATE\n"; push @a, shift @a; } CODE $code =~ s/COUNT/$array_size/; open3(\*PIPE, ">&STDOUT", \*OUTPUT, "perl") or die "Cannot run perl: $!"; $/ = "ITERATE"; print PIPE $code; close PIPE; while () { my $i; if (/Iteration=(\d+)/) { $i = $1; } else { die "Cannot find the iteration in\n$_"; } my $off = /offset=(\d+)/ ? $1 : 0; printf "Iteration%8d: Offset%6d\n", $i, $off; }