oops I missed a line: my $linect="$."; while ( <FILEHANDLE>) { if ( $linect > 9 ) { do whatever ... } $linect++; }
need to use double-quotes around variable $. thanks for the correction... keeps me on my perl learning toes. Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams Eduardo Vázquez Rodríguez <[EMAIL PROTECTED] To orp.com.mx> "'[EMAIL PROTECTED] '" <[EMAIL PROTECTED]>, 'Perl 02/14/2005 06:20 Beginners ' <beginners@perl.org> PM cc Subject RE: Start reading from a specific line Thanks I prove it and worked!!!!! -----Original Message----- From: [EMAIL PROTECTED] To: Perl Beginners Sent: 2/14/2005 5:13 PM Subject: Re: Start reading from a specific line if you want to use a built in function then use $. or its alternatives $NR, or $INPUT_LINE_NUMBER By definition this says "the current input line number of the last file handle that was read." my $linect=$. while ( <FILEHANDLE>) { if ( $linect > 9 ) { do whatever ... } } derek "John W. Krahn" <[EMAIL PROTECTED] > To Perl Beginners <beginners@perl.org> 02/14/2005 04:13 cc PM Subject Re: Start reading from a specific line Eduardo Vázquez Rodríguez wrote: > Hello Perl Programmers Hello, > I have a question regarding openning a file > > How can I start reading a file from n line? > > For example > > I open a File like this way > > open(INPUT, $file) > while (<INPUT>) > { > do something with $_; > } > > But It starts to read from line #1, what I want is that start reading > exactly from line 10. Read the first nine lines before the while loop: open INPUT, $file or die "Cannot open $file: $!"; # get rid of first nine lines <INPUT> for 1 .. 9; while ( <INPUT> ) { do something with $_; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>