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?

> 
> 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>


Reply via email to