Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Getting only part of a text file...

by crashtest (Curate)
on Jun 08, 2006 at 20:52 UTC ( [id://554361]=note: print w/replies, xml ) Need Help??


in reply to Getting only part of a text file...

[Update: GrandFather beat me to it.]

This might be a good place to make use of the flip-flop operator. It can help you avoid the ugly $start / $end / $started variables to keep track of where you are:

use strict; use warnings; while (<DATA>){ # Returns true after matching "LV Name", # and returns false after # matching "--- Logical extents ---". if (/^LV Name/ .. /--- Logical extents ---/){ print "$_"; } } __DATA__ Line above --- Logical volumes --- LV Name /dev/vg00/lvol3 VG Name /dev/vg00 LV Permission read/write ... --- Logical extents --- Line below
Output:
LV Name /dev/vg00/lvol3 VG Name /dev/vg00 LV Permission read/write ... --- Logical extents ---

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found