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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Parsing extremely long lines


New User

Oct 6, 2011, 11:44 AM

Post #1 of 2 (1567 views)
Parsing extremely long lines Can't Post

So I have a file, which consists of multiple very long lines, so long that I don't want to read the entire line for memory concerns. And for each line, I want to count the number of some special character, let's call it X

So a line could be:

....................X........blahlahblah....X...........X......., repeat 1 billion times.

So I have come up with 2 options:

1) pre process the lines and break them up into more manageable chunks. Then process line by line.

2) read a single character at time, do what's need when X is encountered, and go to the next character.

Which one is more efficient? Is there a better way?

(This post was edited by nfw on Oct 6, 2011, 11:46 AM)


Oct 6, 2011, 1:09 PM

Post #2 of 2 (1561 views)
Re: [nfw] Parsing extremely long lines [In reply to] Can't Post

Have a look at Tie::File (, i've had very good experiences in using this module to process huge files.



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

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