in reply to How to restart a while loop that is iterating through each line of a file?

You never rewind the $fh back, so no wonder it reads the next 16 lines in the next iteration of the loop. If $fh points to a real file, you can set its position back to the beginning using seek:
seek $fh, 0, 0;

If $fh is a pipe, socket, or similar, though, it would be better to read 16 lines from it into an array before entering the loop:

my @sixteen_lines = map scalar <>, 1 .. 16; for my $i (0 .. 33) { open my $new_fh, '>>', "$filename$i.vcf" or die $!; print {$new_fh} @sixteen_lines; }

You should probably consider the situation where the input file is shorter than 16 lines. Also, it's unlcear why you're opening the output files for appending.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: How to restart a while loop that is iterating through each line of a file?
by cookersjs (Acolyte) on Nov 29, 2016 at 14:24 UTC
    seek was the exact command I was looking for.

    Thanks very much! -cookersjs