Try this: use strict;
my (%num_map, $max, @pair); while (my $line = <DATA>) { chomp ($line); my @days = split /\|/, $line; foreach my $day (@days) { map { $num_map{$day}{$_}++ } grep $_ ne $day, @days; } } while (my ($num, $href) = each %num_map) { while (my ($sub_num, $count) = each %$href) { if ($count > $max) { @pair = ($num, $sub_num); $max = $count; } } } print "The numbers $pair[0] and $pair[1] appear together most frequently.\n"; exit; __DATA__ 01|05|10|14|22|30 01|10|22|28|31 Peter Guzis Web Administrator, Sr. ENCAD, Inc. - A Kodak Company email: [EMAIL PROTECTED] www.encad.com -----Original Message----- From: steve silvers [mailto:stevesilvers@;hotmail.com] Sent: Sunday, October 20, 2002 12:54 PM To: [EMAIL PROTECTED] Subject: Extracting Common Dates In a nutshell I have a text file with dates in it (01 - 31) that are pipe delimited. In one month I might have. 01|05|10|14|22|30 the next month I might have 01|10|22|28|31 The lowest number is obviously 01, and can reach 31. I need to read in the text file, which is done but I need to know which dates appear together the most. The above example would produce "01 and 10" open(FILE,dates.txt) || die "Can't open dates.txt file $!"; while <FILE> { print "What dates the tasks are done on the most"; print "bla.. bla.. bla.."; } How can I read in a few years worth (on the same text file) and find the dates that appear the most together. Any help greatly appreciated. Thanks in advance Steve _________________________________________________________________ Get a speedy connection with MSN Broadband. Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs