On Jul 18, 6:16 am, [EMAIL PROTECTED] (Ayesha) wrote:
> Hi all
>
> I got started on Perl only today!
> I have a text file in which I need to read a line and the line after
> that. Like
>
> line1 and line2
> line2 and line3
> line3 and line4
>
> when I use while($line1 = <MYFILE>){
> $line = <MYFILE>;
> }
>
> I get output
> line1 and line2
> line3 and line4 ..etc. I guess everytime I read a line, it increases
> the counter and reads the next line. I tried playing with the $.
> variable, but it did not help.
>
> Any suggestions here will be very helpful
>
> thanks
> Ayesha
Hello Ayesha,
This code will do the work.It works for me at
least..
#!/usr/bin/perl -w
$file="mini.txt";
open(FH,"<$file") || die "unable to open file";
while ($line=<FH>)
{
print"$line";
}
close(FH);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/