okarmi has asked for the wisdom of the Perl Monks concerning the following question:
I'm very new to PERL (or programing) and wrote only one script so far. Even though the script runs fine, I have a warning and wish to ask your wisdom to understand it.
The purpose of the script is to parse a log and retrieve the relevant UserID's. After locating the userID in a line in the log I send it to the following sub (AddToUserArray) which inserts it to my user array (only if it wasn't inserted before).
The warning I receive is in the AddToUserArray sub. The warning is: "useless use of private variable in void context at ..." The line it points to is the sub line 18 (yes it only has brackets)
1 sub AddToUserArray { 2 my $UserID=$_[0]; 3 my $i=0; 4 my $Pexists=0; 5 my $Size; 6 7 if($UserID eq "") { # incase a bad UserID was recived. if Pexi +sts=1 it will skip &addtouserlog 8 $Pexists=1; 9 return $Pexists; 10 } 11 12 $Size=scalar(@Participants); 13 for($i;$i<$Size;$i++) { 14 if ($Participants[$i] eq $UserID) { 15 $Pexists=1; 16 last; 17 } 18 } 19 if ($Pexists==0) { 20 $Participants[$i]=$UserID; 21 } 22 return $Pexists; 23 }
Again, the entire script works fine but I want to understand this warning.
Thank you!
|
|---|