in reply to Re: Re^2: when reading a file how to print a line one above the current line??
in thread when reading a file how to print a line one above the current line??

I thought about the efficiency issue, but I guess it boils down to personal choice. With the guarded print you don't get to see a -1:\n should the pattern happen to match on the first line, and really that single test does very little to performance. We could pull out Benchmark here but I suspect the difference would be within measurement jitter (how is this exactly called in English?) for any less than a few hundred thousand lines.

Makeshifts last the longest.

  • Comment on Re^4: when reading a file how to print a line one above the current line??