use strict; use warnings; while (my $line = ) { if ($line =~ /^id:\d+/) { for (1 .. 4) { my $following = ; print $following; } } }