http://www.perlmonks.org?node_id=982702


in reply to Write a Loop

Loops: See Compound Statements.

Finding keywords: See perlreref.

'Extracting': See print or Additive Operators depending on what you mean by extracting.
You will likely need to declare some variables with my and use Auto increment and Auto decrement to count the number of lines you've extracted.

Exiting: See Loop Control.