my $fh = open("file"); for =$fh->$line1,$line2 { # do whatever with the two lines }