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

Re: Reading entire file.

by bjelli (Pilgrim)
on May 04, 2001 at 12:13 UTC ( #77899=note: print w/ replies, xml ) Need Help??

in reply to Reading entire file.

I'll just latch onto one of your questions:

>Is there an easier way to test and print between two points in a file,

Yes, there is. I tried to explain it in

In your case, I'd recommend you break out of the loop after you're finished with the tool:

while (<FOO_FILE>){ if (/$foo/){ $that = 1; } if (/$bar/){ last; # emergency exit from the loop ;-) } if ($that){ print $_; } }

You could also seperate it into two loops, one for searching for the tool, one for reading the lines for that tool.

while (<FOO_FILE>){ last if /$foo/; # ignore all lines until we find foo } while (<FOO_FILE>){ last if /$bar/; print $_; # do something with the lines we find now } close FOO_FILE; # just ignore the rest of the file
Brigitte    'I never met a chocolate I didnt like'    Jellinek

Comment on Re: Reading entire file.
Select or Download Code
Re: Re: Reading entire file.
by NodeReaper (Curate) on May 04, 2001 at 13:13 UTC

    Reason: (azatoth) - pointless (non)contribution to thread

    For more information on this node visit: this

      I'll ask vroom to unreap this node. The reply was exactly what I was thinking when I read the node that it was a reply to.

      I'm disappointed in azatoth for asking for it to be reaped just because s/he didn't understand its criticism. And I'm ashamed that it ended up getting reaped!

      Please only reap obvious trolls and complete duplicates!

              - tye (but my friends call me "Tye")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://77899]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2015-07-06 17:34 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (77 votes), past polls