open my $fh, '<', 'infile'; while( <$fh> ) { # do something with $_. } my @remainder = <$fh>;