Is there a way to have map return no value (compared with null value) into the output array if a given condition on the input scalar is not met?Well, yes. I think $foo eq $bar ? $_ : () would do it (among other possibilities). But why not just use grep instead?
my @grepped = grep {$_->{'username'} eq $cgi->param('username')} @{ %{$xml}->{'user'} };
In reply to Re: foreach/map equivalency
by ChemBoy
in thread foreach/map equivalency
by rob_au
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |