in reply to How do you define "elegant"?
half of those lines are unnecessary!my @new_foo; foreach my $a_foo (@foo) { $a_foo = '%'.$a_foo.'%'; push @new_foo, $a_foo; } @foo = @new_foo;
modifies each element of @foo in place without the extra @new_foo. i love map, but unless you need both lists when you are done, it's rarely the right tool. benchmark the above foreach against the map, and you should find it to be much faster.foreach my $a_foo (@foo) { $a_foo = '%'.$a_foo.'%'; }
(elegance means ignoring such things when performance is unimportant..)
|
|---|