Stuart White wrote:
>
> 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.
Don't. Just dump the array and use a hash from the start.
> #!/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;
This is acting on the whole array and the whole hash. Why is it
inside a loop?
>
> $num++;
> }
> while (($key,$value) = each(%linehash))
> {
> print "$key:$value\n";
> }
> }
> print "@line";
It doesn't have to be so complcated.
if ($_ =~ /(\w+\b) (Jump Shot)/)
{
$jumpshots{$1}++;
}
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]