in reply to pause output when printing an array to the screen
Here's a potential solution using the each() for arrays feature in 5.12:
#!/usr/bin/perl use warnings; use strict; use 5.12.0; my @array = ( 'aa'..'zz' ); while ( my ( $i, $elem ) = each @array ){ if ( $i != 0 && $i % 20 == 0 ){ say "Hit ENTER to continue..."; <STDIN>; } say $elem; }
If you don't have perl v5.12+, you'll need to use an external iterator:
my $i = 0; for my $elem ( @array ){ if ( $i != 0 && $i % 20 == 0 ){ say "Hit ENTER to continue..."; <STDIN>; } say $elem; $i++; }
|
|---|