#!/usr/bin/env perl use strict; use warnings; my $infile = q{pm_read_part_file.in}; my $outfile = q{pm_read_part_file.out}; my $start = 3; my $end = 5; open my $in_fh, q{<}, $infile or die qq{Can't open $infile for reading: $!}; open my $out_fh, q{>}, $outfile or die qq{Can't open $outfile for writing: $!}; while (<$in_fh>) { next if $. < $start; last if $. > $end; print $out_fh $_; } close $in_fh; close $out_fh;