in reply to How could I make this code more optimized

  1. I would use values instead of referencing keys repeatedly. I have no idea if this is any faster. Anyone?
    (Update: Well, if japhy agrees, that's good enough for me...)
  2. I would do the date test before looping through the Messages.
  3. I'd use grep instead of what you have, but probably for no good reason. If it's appropriate, looping through Messages can be further improved by making it break out early when a match is found...
open(RPT,">$DIR/$RPT")||die"Can't open $RPT: $!\n"; print RPT "Report Date: $month/$day/$year\n"; print RPT "$RPT\n"; print RPT "============================\n"; foreach my $value (values %hash) { next unless $value->{date} =~ $DATE; next unless grep { $value->{error_message} =~ /$_/ } @Messages; print RPT ... ... } close RPT;

buckaduck