Hmm, this might actually be more productive I showed
less abstract example lines.  (I couldn't do this
before as I didn't have the code in front of me.)
Here is an example of the lines that my code is
selecting and then extracting a player name and jump
shot attempt(working on this part) then putting into
an array.  If I were to print out the array with each
element on a separate line(assuming I had the count
thing working) this is what it would look like(below
the sample text)

(11:23) [SAN 2-0] Bowen Jump Shot: Made (2 PTS) 
(11:10) [PHX] Marbury Jump Shot: Missed
(11:07) [PHX] Marion Jump Shot: Missed
(10:51) [SAN 4-0] Jackson Jump Shot: Made (2 PTS) 
(10:23) [SAN] Jackson Jump Shot: Missed 
(9:43) [SAN] Duncan Jump Shot: Missed 
(8:43) [SAN] Bowen Jump Shot: Missed
(8:31) [PHX] Stoudemire Jump Shot: Missed
(8:09) [SAN] Jackson Jump Shot: Missed
(7:42) [PHX] Hardaway Jump Shot: Missed
(7:09) [PHX] Stoudemire Jump Shot: Missed
(6:50) [SAN] Bowen Jump Shot: Missed
(6:15) [SAN 10-2] Duncan Jump Shot: Made (4 PTS) 
(5:52) [PHX] Williams Jump Shot: Missed
(5:46) [PHX 5-10] Marion Jump Shot: Made (5 PTS) 
(5:06) [SAN 12-7] Ginobili Jump Shot: Made (2 PTS) 

Bowen 1
Marbury 1
Marion 1
Jackson 1
Jackson 2
Duncan 1
Bowen 2
Stoudemire 1
Jackson 3
Hardaway 1
Stoudemire 2
Bowen 3
Duncan 2
Williams 1
Marion 2
Ginobili 1

Right now my array is just like that, minus the
numbers.  So what I want to do is assign the array to
a hash.  If I were to do that, my understanding is
that the names would be keys and the numbers values,
and doing such an assignment in a loop would cause
some entries to be overwritten.  As soon as "Bowen 2"
shows up as an array element, "Bowen 1" is
overwritten.  This is what I want it to do.

Using the array output above, this is what I would
expect to happen upon the array being assigned to the
hash and the hash being printed out:

Marbury 1
Jackson 3
Hardaway 1
Stoudemire 2
Bowen 3
Duncan 2
Williams 1
Marion 2
Ginobili 1

How can I assign my array to a hash, have an
individual counter for each player every time he
attempts a Jump Shot, and then have output from my
hash like shown above?

Oh, presently, my code is printing the name, which is
the key, and then a colon, and then another name,
ofwhich I'm not sure is coming from.  It also is
printing this error message:
"Use of uninitialized value in concatenation (.) or
string at statsll.pl line 24, <STATS. line 507"
line 24 is this line: print "$key:$value\n";
I don't know what this all means.

code is below
Thanks in advance. -stu
Oh, and James, thanks for your help, but I don't think
I was as clear as I should have been.

#!/usr/bin/perl 

use warnings;
use strict;

open(STATS, "stats.txt") or die "statfile\n";
my $key;
my $value;
my %linehash;
my @line;
my $player;
my $num = 0;
while (<STATS>)
{
if ($_ =~ /(\w+\b) (Jump Shot)/) 
{
 $player = $1;
 push(@line, $player);
 %linehash = @line;
 $num++;
}
while (($key,$value) = each(%linehash))
{
 print "$key:$value\n";
}
}
print "@line";



__________________________________
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]

Reply via email to