Home: Perl Programming Help: Intermediate:
Read only one line from text file



ragha12
Novice

Sep 22, 2011, 9:39 PM


Views: 1646
Read only one line from text file

Hi,
I am using strawberry perl in windows and perl express IDE
I have a text file that contains 10 lines, i have to print only 1 line from that text file......and we have to use only while loop......

this is the code that i have.....
this code is printing all the lines....

#!/usr/bin/perl
open (MYFILE, 'dmb.txt');
while (<MYFILE>) {
chomp;
print "$_";
}
close (MYFILE);


Thank you...Smile


rovf
Veteran

Sep 23, 2011, 12:05 AM


Views: 1634
Re: [ragha12] Read only one line from text file

Don't post the same question to more than one forum (without indicating so).