use strict; use warnings; # ... sub parse_from_handle { my ( $handle, ) = @_; while ( my $line = <$handle> ) { # parse lines here until a end condition strikes # ... last if $end_condition; } return # ... } # MAIN my $file = shift @ARGV || die "no file given to read from\n"; open my $fh, '<', $file or die "open($file,ro) failed: $!"; # feed handle to subroutine parse_from_handle( $fh ); close $fh;