joggi
New User
Feb 14, 2014, 9:15 AM
Views: 2358

Matching with multiple lines



$log1 = "Generating an unsorted array took 1.259 seconds\n"; $log1 .= "Sorting took 10.486 seconds\n"; $log1 .= "Generating an unsorted array took 1.346 seconds\n"; $log1 .= " Sorting took 9.276 seconds\n"; $count = 0; $_ = $log1; while (/^Generating.*Sorting/smg) { $count ++; print "3: Match $count found at $[0] to ",$+[0]1,"\n"; } print "Total number of matches found: $count\n\n"; I'm trying to get the start of the line with generating, so it should have 2 matches, with 2 start and end points for each line where it starts. I've only been learning it for 2 weeks now, so I'm completely new, any help would be much appreciated.
