in reply to Get file part from the section where the matched pattern is found.

To give you exact code, I'd want to see your data. That often gives clues as to the best way to approach the problem. But here's a general solution:

use strict; use warnings; { local $/ = undef; ### Set line terminator to nothing open(HANDLE, 'test.txt') || die; $_ = <HANDLE>; ### Slurp entire file } ### Match everything at or following first instance of pattern if (m/(my pattern.*)/s) { print $1; } else { print "No match found.\n"; }
  • Comment on Re: Get file part from the section where the matched pattern is found.
  • Download Code