#!/usr/bin/perl -w ########################################################### # # Given a year displays the winner of the # NCAA Division I basketball tournament # Author Bill Kraynek # Created November 15, 2006 # ########################################################### $year = $ARGV[0]; if( $year< 1939 || $year > 2007 ) { print "Year $year is out of range!\n"; exit 1; } %winners = (); open(FILEIN,"ncaa2007.data"); while( ) { if( $_ =~ /^$year/ ) { @fields = split(/:/,$_); @winners{$fields[1]} += 1; }#end if }#end while close(FILEIN); $numwins = 0; foreach $team ( keys (%winners)) { if( $numwins < $winners{$team} ) { $winner = $team; $numwins = $winners{$team} } } print "The winner for $year was $winner.\n";