sub AddToUserArray { my ($UserID) = @_; # Like this because it scales well for many params # return 1 to skip addtouserlog () # return if bad UserID return 1 if $UserID eq ""; # return if handled user already return 1 if grep {$_ eq $UserID} @Participants; push @Participants, $UserID; return; # Generally better to return undef than 0 } #### use strict; use warnings; my %Participants; while () { chomp; my ($name, $tail) = split / /, $_, 2; next if ! defined ($name) || exists $Participants{$name}; $Participants{$name} = $tail; print "Added $name: $tail\n"; } __DATA__ Fred Red team Joe Blue Team Pete Blue Team Fred Red Team Annie Red Team Lee Green Team Steve Green Team #### next if ! defined ($name) || exists $Participants{$name}; $Participants{$name} = $tail;