$VAR1 = {
'MARINERS' => [
'GRIFFEY',
'PEREZ'
],
'REDS' => [
'GRIFFEY',
'PEREZ',
'ROSE',
'BENCH'
],
'PHILLIES' => [
ROSE'
]
};
####
$VAR1 = {
'MARINERS' => [
'GRIFFEY',
'PEREZ'
],
'REDS' => [
'GRIFFEY',
'GRIFFEY',
'PEREZ',
'ROSE',
'BENCH'
],
'PHILLIES' => [
'ROSE',
'ROSE'
]
};
####
use strict;
use constant DEBUG => 2;
my $team;
my $player;
my %teamAccts;
my %teamAcctsUniq;
my $teamAccts;
my $teamAcctsUniq;
while () {
chomp;
if ( (/^T:/) ){
$team = (split /:/) [1];
}
if ( (/^P:/) ) {
$player = (split /:/) [1];
push( @{$teamAccts{$team}}, $player);
}
}
my %seen;
@$teamAcctsUniq = grep { ! $seen{$_->{player}}++ } @$teamAccts;
#print Dumper(\%teamAccts);
print Dumper(\%teamAcctsUniq);
__DATA__
T:REDS
P:GRIFFEY
P:GRIFFEY
P:PEREZ
P:ROSE
P:BENCH
T:PHILLIES
P:ROSE
P:ROSE
T:MARINERS
P:GRIFFEY
P:PEREZ