Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Caputre Entire Line Not Just Find

by kennethk (Abbot)
on Jul 13, 2016 at 16:32 UTC ( [id://1167707]=note: print w/replies, xml ) Need Help??


in reply to Caputre Entire Line Not Just Find

If you want to grab everything via capture, you'll need to match everything:
while (<FILE>) { if (/(.*$find.*)/) { $header = $1; } elsif (/^\s{38}\S*/) { print NEW "$header\t", $_; } }
Note that . matches every character but a newline, so there's no need to worry about chomping. See s in Modifiers in perlre.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Caputre Entire Line Not Just Find
by jlope043 (Acolyte) on Jul 13, 2016 at 16:41 UTC

    Thank you kennethk, this is exactly what I was trying to accomplish. Truly appreciated.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-20 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found