in reply to parsing multiple lines

The advice above about setting flags to track what sort of input you are currently examining and using those flags to drive what and how to write your output is on the mark and exactly how I approach this issue when writing www scraping tools. The only thing I want to add is a comment to your remark, that you "would like a solution where I don't have to use any modules or subroutines."

Modules and subroutines are how we re-use code. Code re-use is essential to writing testable code, minimizing bugs and copy-n-paste errors, expediting development and refactoring, avoid re-inventing wheels and leverage the work and wisdom of others to serve our own applications. Don't fear code re-use. It will make you a stronger developer.

-- Hugh

if( $lal && $lol ) { $life++; }