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.