in reply to Re: Useless use of private variable in void context
in thread Useless use of private variable in void context
Using for(my $i=0; $i<$Size; $i++) is wrong here, because it means that $i will be 0 after the loop, while another part later on requires it to be scalar @Participants.
Note that there's a much more perlish way to write the whole loop:
for my $p (@Participants) { if ($p eq $UserID) { return 1; } }
If the user ID was not found, $i will always be the array size. Which means that you can replace $Participants[$i]=$UserID; with push @Participants, $UserID;, which is a bit more readable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Useless use of private variable in void context
by okarmi (Initiate) on Oct 12, 2009 at 10:57 UTC | |
by moritz (Cardinal) on Oct 12, 2009 at 11:10 UTC | |
by okarmi (Initiate) on Oct 12, 2009 at 11:28 UTC | |
by MidLifeXis (Monsignor) on Oct 12, 2009 at 14:19 UTC | |
by GrandFather (Saint) on Oct 13, 2009 at 19:38 UTC |