in reply to foreach/map equivalency
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'} };
|
|---|