I'm doing the same thing over and over again for hours with no results!
Seems very stupid but help me find what is wrong ...
I have two arrays:
@tirar that grabs user form input (checkbox)
@thecats - populated from DB in form of 1|43|56|74 ($mailcats)
The script is supposed to remove the values @tirar from @thecats.
I can print the results after subtract BUT instead of x|y|z I'm getting x|y|z| (note the | at the end)
I can't get rid of the last | no matter what I do.
I appreciate your help.
Seems very stupid but help me find what is wrong ...
I have two arrays:
@tirar that grabs user form input (checkbox)
@thecats - populated from DB in form of 1|43|56|74 ($mailcats)
The script is supposed to remove the values @tirar from @thecats.
I can print the results after subtract BUT instead of x|y|z I'm getting x|y|z| (note the | at the end)
I can't get rid of the last | no matter what I do.
Code:
my @tirar = $IN->param('apagar');
my @thecats = split(/\|/,$mailcats);
my ($teste,$i);
# unique ---------
my %exclude = map {$_,$_} @tirar;
@thecats = grep {!exists($exclude{$_})} @thecats;
my $tamanho = @thecats;
for ($i=0;$i<=($tamanho-1);$i++){
if($thecats[$i] ne ""){
$teste .= $thecats[$i] . "|"; }
#$teste .= $thecats[$tamanho];
}
$teste .= $thecats[$tamanho+1]; # adding 1 or not doesn't change results?????
I appreciate your help.