open IN, "a.txt";
while(<IN>) {

  if ( ....next line awaited.... ) {
    $_ = <IN>
    ........
    ........
  }

}
close IN;


Reading from opened filehandle in the scalar context reads one line only.
$line = <IN>;

Reading from opened filehandle in the array context reads whole file (the
rest of th file).
@lines = <IN>;

-- Petr Smejkal

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Saxena, Saurabh
> Sent: Monday, June 04, 2001 10:44 AM
> To: 'Perl1'; 'Perl2'
> Subject: How to read a single line from file
>
>
> I am using a while loop to read a file like
>
> open (IN, "a.txt" ) )
> while(<IN>)
> {
> ---
> ---
> }
>
>
> This will read the entire file reading line by line.Now the
> problem is that
> inside the while loop at some particular place i want to read just one
> line(next line) without going back to main loop.I am trying using readline
> function but it is not working
>
> open (IN, "a.txt" ) )
> while(<IN>)
> {
> ---
> ---Here i want to read the next line without going back to the main loop
> ----
> }
>
>
> Please let me know how to do it
> regards
> Saurabh
>
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to