my @c= map {
my $v=$_;
map {$_ * $v } @m
} @a;
Is using map like this, a good practice? Why not?
If not, what are other ways?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I cannot answer whether or not it is good practice. In general there are a lot of situations in which I use nested maps a lot. It’s short, it’s concise and to the point.
However, such nested maps are always in danger of growing just slightly too big and unwieldy in which case they become harder to read than they have to (which list does
$_refer to in which case!?). So use them, yes, but use it with caution — just like all other similar things that make Perl so terse and expressive.