On Mon, 8 Nov 2004, Joseph Paish wrote:

> how do you use the "line number" variable inside a while loop like i am 
> trying to do below?  

Why not go about the problem like this?

  #!/usr/bin/perl

  use strict;
  use warnings;

  open (fh1, "/path/to/file") or
    die ("can't open /path/to/file: $!");

  my $first = 0;

  while (<fh1>) {
    if ( $first > 1 ) {
      my @initial_values = split / /, $_ ;
      # process intial values here
      $first++;
      next;
    } else {
      # process subsequent values here
    }
  }
  close (fh1);

That is:

 * use a temp variable that you manage yourself
   (this, in my opinion, is more readable anyway)

 * use the $! variable in the die statement
   (that way, if it fails, you know why it failed)



-- 
Chris Devers

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