in reply to How to restart a while loop that is iterating through each line of a file?
#!/usr/bin/perl use strict; use warnings; my $filename = '16lines.txt'; open (INFILE, '<', $filename) or die "unable to read the file with 16+ lines $!"; my @lines = <INFILE>; #read all lines into an array for my $file_no (0..33) #total 34 files?? Really? Maybe 0..31? { open (my $fh, ">", "$filename$file_no.vcf") or die "problem opening $filename$file_no.vcf Oops $!"; print $fh grep{defined}@lines[0..15]; # the grep on defined lines is in case there are less # 16 lines in the input file. I am sure there are other # with perhaps split() to accomplish the same thing. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to restart a while loop that is iterating through each line of a file?
by Laurent_R (Canon) on Nov 28, 2016 at 23:32 UTC | |
|
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:28 UTC | |
by Marshall (Canon) on Nov 29, 2016 at 21:59 UTC |