I'm confused about greediness. This is the line that I'm trying to match: Spurs 94, Suns 82
This is my regex: if ($_ =~/(Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|Sixers|Bobcats)/) I need to do that because the line could be: Grizzlies 84, Wizards 98 or any combination of teams that are separated by |. But Spurs 94, Suns 82 is the text file I'm currently working with. So, my regex DOES match: Spurs 94, Suns 82 What I'd really like is it to match 'Spurs' skip the spaces numbers and comma, and match 'Suns' in $1 and $2. So I tried this: if ($_ =~/(Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|Sixers|Bobcats)' 94, '(Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|Sixers|Bobcats)/) and I got the command line. I tried (\w\d\d,\w) in between the teams or what is $1 and $3, and I still got the command prompt. I then thought, maybe if I put a {1} next to the first set of teams, it would stop there, and that would just match 'Spurs' that of course, didn't work. So now I'm here. Any idea what the problem is? Here's the entire code: ---------------------------- open(STATS, "stats.txt") or die "statfile\n"; my $team = '\w{3}'; my $player = '\w+'; my @SAN; my @PHX; my %PHX; my %SAN; my @teams; my $team1; my $team2; my %teamOne; my %teamTwo; my @firstTeam; my @secondTeam; #match lines first looking for the team abbreviation #and then the player's name. OR match lines #looking for the team and/or team with score, then #the player name, then Assist, or Block, or Steal, or #replaced by and the name following. #this will get all players that played in the game. while (<STATS>) { if ($_ =~/(Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|Sixers|Bobcats)/) { push (@teams, $1); } if ($_ =~/(Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|Sixers|Bobcats)/) { push (@teams, $1); } $team1 = $teams[0]; $team2 = $teams[1]; if (($_ =~ /\[($team)\] ($player)/) || (m/\[([A-Z0-9 -]+)\] (\w+).+(?:Steal|Assist|Block|replaced by): (\w+)/)) { if ($1 eq $team1) { unless ($2 eq "Team")#exclude Team as "Team rebound" matches { $teamOne{$2}++;#adds the matched Spur to the %SAN hash } } elsif ($1 eq $team2) { unless ($2 eq "Team")#exclude Team as "Team rebound" matches { $teamTwo{$2}++;#adds the matched Sun to the %PHX hash } } } } #the keys are the player names, put player names into an array @firstTeam = keys %teamOne; @secondTeam = keys %teamTwo; #print team roster, pause, print other team roster. print "$team1 roster: @firstTeam\n"; sleep 2; print "$team2 roster: @secondTeam\n"; __________________________________ Do you Yahoo!? Yahoo! Search - Find what you’re looking for faster http://search.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>