I am reading in a file of one line sentences, and then selecting to store several sentences into an array based upon the presence of some key words. I then want to assign the array to a hash. The output of the array will look something like this:
Player1: 1 Player2: 1 Player3: 1 Player1: 2 Player1: 3 Player4: 1 Player3: 2 Player2: 2 If this were the array in total, I would expect, or at least want my hash to look like this (given that it just happens to be sorted alphabetically): Player1: 3 Player2: 2 Player3: 2 Player4: 1 is that a correct expectation? Also, to get the numbers to the right of the colon, I'd have to have a count for each occurrence of each player, how might I do that? The code I have so far is below. I didn't include anything with hashes because everything I tried so far gave me unexpected and unwanted results. So, how do I assign an array into a hash? by assigning an array to a hash, it will overwrite common key values, correct? (Player1, Player2, etc) How can I maintain a separate count for each player's line? (A player's line is a line inwhich his name appears in a selected line) thanks in advance for any help. -stu > #!/usr/bin/perl > > use warnings; > use strict; > > open(STATS, "stats.txt") or die "statfile\n"; > > my @line; > my $player; > my $num = 0; > while (<STATS>) > { > > if ($_ =~ /(\w+\b) (Jump Shot)/) > { > push(@line, $1); > $num++; > } > } __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]