use strict; use warnings; use List::Util qw( reduce ); print factorial(5), "\n"; sub factorial { return reduce { $a * $b } 1 .. $_[0] || 1; } __END__ __OUTPUT__ Name "main::a" used only once: possible typo at mytest.pl line 10. Name "main::b" used only once: possible typo at mytest.pl line 10. 120