|
|
| There's more than one way to do things | |
| PerlMonks |
Re^3: Problems with map(function, array)by eyepopslikeamosquito (Canon) |
| on Dec 10, 2012 at 21:36 UTC ( #1008169=note: print w/ replies, xml ) | Need Help?? |
|
Your original code with strict and warnings: gives the warning "Use of uninitialized value $_[0] in multiplication (*) at map1.pl line 3". This is how it should be written: which produces 2 4 6 as expected. BTW, Conway, in Perl Best Practices, chapter 8, recommends always using the block form of map, not the expression form that you are using. The expression form might be faster than the block form though (if that matters, you should benchmark it).
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||