How do I read line by line of data from a file using perl 
Author Message
 How do I read line by line of data from a file using perl

Hi,

How do I read line by line of data from a file using perl ?
I have file, each line has some instructions...
I need to read each time and do some processing.

Thanks,

Yatin.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 How do I read line by line of data from a file using perl

Quote:

>How do I read line by line of data from a file using perl ?
>I have file, each line has some instructions...
>I need to read each time and do some processing.

Read the FAQ.

--

All life's answers are on TV. - Bart Simpson



Wed, 18 Jun 1902 08:00:00 GMT  
 How do I read line by line of data from a file using perl
# first you need to open a filehandle to the file...

open (DB, "yourfilenamehere");

while(<DB>) {            # while there are still lines in your file, (it
will read one at a time)
        print $_;                # $_ represents each line as it's read, so
do whatever you want to $_

Quote:
}

close(DB);                # close your filehandle

# hope this helps!



Wed, 18 Jun 1902 08:00:00 GMT  
 How do I read line by line of data from a file using perl
On Wed, 22 Nov 2000 17:51:17 -0500,

Quote:
> # first you need to open a filehandle to the file...

> open (DB, "yourfilenamehere");

You might as well teach them some good habits:

open(DB, "yourfile") or die "Cannot open 'yourfile' for read: $!";

Martien
--
Martien Verbruggen              |
Interactive Media Division      | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.   | selective about its friends.
NSW, Australia                  |



Mon, 12 May 2003 10:16:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. newbie perl question - reading a file line by line

2. Sorting multiple-line data to single line data

3. how to read a huge file line by line without loading it into memory

4. reading lines from one file and pulling matching lines in another

5. Line by line file reading

6. How to read a file line by line w/loop

7. Read remote text file line by line

8. reading a file line by line backwards

9. read last line without reading previous lines, how?

10. using Unicode::String to read a line from a file

11. read line by line in perl

12. Using Perl to read a serial line

 

 
Powered by phpBB® Forum Software