Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
To print the first and last line of each file:
To find the first and last match for a pattern: (In this case, 'DT=20011105.112009'-style time-stamps in a log file) In this case there can be more than one such pattern on a line and it's the first one that is valid. The point being that the /s makes a greedy, black-hearted .* for going straight to the end of the (presumedly long) file, ignoring linebreaks.   Then the /m (together with the ? to reign in dot-star) allows backtracking by line to find the first match on a line with matches.   update:   These started out (obviously) as one liners, then got thrown into files.  The first time I actually looked at them was when I grabbed them to throw up here which, of course, lead to exploring MTOWTDI.  The first seems clearest this way. The second started out being far more complicated which is why it's in multi-line /x format.   p In reply to Re: Call for code samples!
by petral
|
|