http://www.perlmonks.org?node_id=404872


in reply to Searching in an array of arrays

One way to do it (untested) :
my $consecutive = 5; my ($last_range, $first_day); my %ranges = ( '15' => 'mild', '20' => 'warm', '25' => 'verywarm', '30' => 'hot', '35' => 'veryhot', '40' => 'extremelyhot'); foreach my $day (@data) { $day->[1] = int $day->[1]; my $range = $day->[1] - ($day->[1] % 5); if ($range == $last_range) { $seen++; } else { $last_range = $range; $first_day = $day->[0]; $seen = 1; } if ($seen == $consecutive) { print "$first_day $day->[0] " . $ranges{$range} . "\n"; } }
BTW, a hash table would probably be more appropriate to store your tempature information.

updated : corrected $last_range and $first_day, and make it word in Real world


--
zejames