$title = $1 if $LINES[0] =~ /title: (.*)$/i;
# though $[ is better than zero
$submitted_date = $1 if $LINES[15] =~ /submitted: (.*)$/i;
# But how do you know its line 16?
####
# use push on the off chance you've got multiple files w/
# the same sub date
push @{$dates{$submitted_date}}, $FILE;
####
foreach $key (keys %include) {
if ($include{$key} eq 'yes') {
print "$titles{key}
$titles2{$key}
\n";
}
}
# try instead:
foreach my $date ( sort keys %dates ) {
foreach $key ( @{$dates{$date}} ) {
if ($include{$key} eq 'yes') {
print "$titles{key}
$titles2{$key}
\n";
} # if include eq yes
} # foreach key @dates
} # foreach date dates
####
while ($term = shift @terms ) {
print "$term";
print ", " if @terms;
}