Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Read forward and backward - need help

by MZSanford (Curate)
on Jan 17, 2003 at 20:59 UTC ( #227797=note: print w/replies, xml ) Need Help??

in reply to Read forward and backward - need help

Depending on how rigid the format is, maybe something like this :

use strict; $/ = "\n\n"; while (my $record = <>) { chomp($record); # $record contains all needed lines # from START OF RECORD to END OF RECORD }

If you are planning to have 1000's of line between begining and end, and are really worried about memory usage, you may want to save each start when you encounter it, then if you find the data you want, seek() back. From what i can gather this is similar to what you do now, only without the full scan of the file

Above code is untested and was typed into this page with no warranty or promise with the hope it will help. Misuse may result in premature baldness. Your milage may vary.

Update : Fixed syntax error
from the frivolous to the serious

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://227797]
[LanX]: he ... FB is banning the wistleblower ... (shoot the messenger)
[marto]: #deletefacebook
[LanX]: well try to find my profile xD
[marto]: derp
[marto]: I've never had an account, and wouldn't visit the site
LanX having only a fake profile is hard if a flirt asks to befriend you
[erix]: "surveillance companies" have been rebranded as "social media"
[LanX]: I'm using whatapp though :-/
[LanX]: Snowden remins me of Evan Spiegel (... start of a new conspiracy theory)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2018-03-19 15:24 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.