in reply to Check multiple lines exist in a record
I don't think anyone has mentioned changing the record/line delimiter yet which seems like a good approach for this problem especially if you have multiple records in a file. You asked about processing line by line. That's the default because the delimiter ($/) is a newline (\n) by default (usually, different systems and read modes affect this too). You could play around with this.
{ local $/ = "<SUBEND"; # localize or this is a bad idea. my $count = 0; while (<YOUR_FILE_HANDLE>) { next unless /SUBBEGIN/; # Don't catch trailing empty stuff. print "\nRECORD ", ++$count, " -------------------------\n"; print $_; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Check multiple lines exist in a record
by hippo (Archbishop) on Mar 26, 2018 at 16:11 UTC | |
by Your Mother (Archbishop) on Mar 26, 2018 at 16:15 UTC |