the snippet of code:
$playerName = param('player');
$found = 0;
getPlayers();
$i = 0;
for ($a = 0; $a <= $#data; $a++) {
if ($data[$a] eq $playerName) { $found = 1; } # PROBLEM LINE 🙁
else { $newData[$i] = $data[$a]; $i++; }
}
if ($found == 0) { print "$playerName not found.<P>\n"; }
else {
open (FILE,">players.txt") || die $!;
foreach ( @newData ) { print "$_\n"; }
close (FILE);
print "$playerName was found and removed.<P>\n";
}
OK, basically all this section does from beginning to end is grab a value (playerName) from the web form. getPlayers gets data from a text file and puts it into @data. The following for loop then sifts through @data (or so it should) and attemps to compare it to $playerName, if it finds a match it says so and does not include that match in @newData, which would be that exact array without the "match".
Incase you haven't guessed by now this is just a peice of code to remove a specified name from a list of names.
Can anyone help with this?!
$playerName = param('player');
$found = 0;
getPlayers();
$i = 0;
for ($a = 0; $a <= $#data; $a++) {
if ($data[$a] eq $playerName) { $found = 1; } # PROBLEM LINE 🙁
else { $newData[$i] = $data[$a]; $i++; }
}
if ($found == 0) { print "$playerName not found.<P>\n"; }
else {
open (FILE,">players.txt") || die $!;
foreach ( @newData ) { print "$_\n"; }
close (FILE);
print "$playerName was found and removed.<P>\n";
}
OK, basically all this section does from beginning to end is grab a value (playerName) from the web form. getPlayers gets data from a text file and puts it into @data. The following for loop then sifts through @data (or so it should) and attemps to compare it to $playerName, if it finds a match it says so and does not include that match in @newData, which would be that exact array without the "match".
Incase you haven't guessed by now this is just a peice of code to remove a specified name from a list of names.
Can anyone help with this?!