sub read_file { open my $FH, '<', 'FileName' or die $!; while (<$FH>) { ....process lines... } }