In Perl, if you have a loop like this:
foreach (@items) {
perform_action($_);
}
you can replace it with a call to map in void context:
map {
perform_action($_)
} @items;
Are there any advantages or disadvantages to doing to? Does it have a performance impact because Perl thinks it has to save the results? Does it improve/worsen readability?
Starting from Perl 5.8.1 map in void context is not expensive:
But the postfix form of
formay be more readable: