dkhalfe has asked for the wisdom of the Perl Monks concerning the following question:
Hi all - the code is not in its proper format nor am I using proper syntax. I believe my question can be answered with a general representation of my code
my $x=0; for (my$a=0; $a<10; $a++) { open (file); while <my $line = file> { $x++; if ($x==1) { print $header, "\n"; (@keys) = split (/\t/, $line); } else { *Does some filtering as each line is read in* } } }
question: I need to print the header and split the line + store into an array ONCE per iteration. Meaning everytime the for loop iterates, the while loop will be carried out. When the while loop is carried out, I need the first part (the if statement) to execute once, and only once. How would I go about doing this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reset a vairable inside a for loop inside a while loop
by davido (Cardinal) on Aug 09, 2012 at 19:02 UTC | |
|
Re: Reset a vairable inside a for loop inside a while loop
by roboticus (Chancellor) on Aug 09, 2012 at 19:32 UTC |