http://www.perlmonks.org?node_id=422338


in reply to Re^2: Who's a thief? -- the follow up
in thread Who's a thief? -- the follow up

...one problem that happens with larger systems like this is the systems tend to rely heavily on recursion and this is not Perl's strength :/
You're not giving perl enought credit for what it can do. The following program executes in under 9 seconds on my (1GB) machine.
#!/usr/bin/perl -w print deep(2_500_000); sub deep { $_[0]>0 ? deep($_[0]-1) : "done\n"; }
...and I can calculate the 36th fibonacci number using the simplistic algorithm below in about a minute. It ends up calling "fib" over 48 million times.
#!/usr/bin/perl -w $count = 0; my $n = ($ARGV[0] < 1) ? 1 : $ARGV[0]; print fib($n)."\ncount = $count\n"; sub fib { $count++; $_[0]<2 ? 1 : fib($_[0]-2) + fib($_[0]-1) }


-- All code is 100% tested and functional unless otherwise noted.