CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



ragha12
Novice

Sep 22, 2011, 9:39 PM

Post #1 of 2 (1136 views)
Read only one line from text file Can't Post

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

Post #2 of 2 (1124 views)
Re: [ragha12] Read only one line from text file [In reply to] Can't Post

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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives