Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) 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

In reply to Re: Read forward and backward - need help by MZSanford
in thread Read forward and backward - need help by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-23 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found