use constant { TITLE => 3, RT => 7 }; { # extra block so that $/ retrieve its previous value after reading this file local $/ = ""; # Paragraph mode while (my $record= ) { my @lines = split "\n", $record; $TI = "$1" if $lines[TITLE] =~ /^TITLE=(.*)/; $RT = "$1" if $lines[RT] =~ /^RTINSECONDS=(.*)/; } } #### { local $/ = ""; # Paragraph mode RECORD: while (my $record = ) { my @lines = split "\n", $record ; $TI = undef; $RT = undef; for my $line (@lines) { $TI = "$1" if $line =~ /^TITLE=(.*)/; $RT = "$1" if $line =~ /^RTINSECONDS=(.*)/; next RECORD if defined $TI and defined $RT; # skip to next record } } }