use strict; $/ = "\n\n"; while (my $record = <>) { chomp($record); # $record contains all needed lines # from START OF RECORD to END OF RECORD }