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


in reply to Text File Section Extractor

I second toolic's suggestion of range operators as a way to simplify the extraction itself.

Two other small things: first, check out the 3 argument form of open with lexical filehandles. You get the general benefits of lexical variables, and these filehandles are far easier to pass around. Second, autodie saves you from a lot of boilerplate code with open and close (to name just two):

use autodie qw/open close/; open my $fh, '<', 'filename'; while (<$fh>) { # Do stuff here } close $fh;