On Monday 08 November 2004 10:56, Bob Showalter wrote: > Joseph Paish wrote: > > how do you use the "line number" variable inside a while loop like i > > am trying to do below? > > > > i never get to process the first line of the file, and as a result, > > subsequent calculations are inaccurate. it always jumps to the > > second "if" statement. > > The way you're using it looks OK to me, so something else is going on. How > do you know the first if() block is not being executed?
i am using the perl debugger under emacs. when i display $. after it enters the second if() block, it shows some seemingly random number. also, with the debugger, i can watch the logic that is being followed, and it never enters the first "if" structure. what i have included below is a very small part of a program that spans several hundred lines and i thought i had cleared up all the logic problems except this one. if the code that i have included below looks good (and it has been basically pulled straight out of the actual program), then i guess i have a logic problem somewhere that i haven't found yet. i'll keep looking. thanks joe > > > thanks > > > > joe > > > > ========= > > > > #!/usr/bin/perl > > use strict ; > > use warnings ; > > > > open (fh1, "/path/to/data/file.txt") or die ("arg123 ... no can do") ; > > > > while (<fh1>) { > > chomp ; > > if ($. == 1 ) { # first line is initial values > > my @initial_values = split / /, $_ ; > > # process intial values here > > } > > > > if ($. > 1) { > > #process subsequent values here > > } > > > > } # end of while loop > > > > close (fh1) ; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>