in reply to Re^2: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
in thread Is it possible to create a sub exclusive to a sub?

Aside from the obvious fact that you don't need a recursive routine to do a fibonacci sequence, I'm still wondering why anonymous subs would ever be preferable to named subs. Is there a measurable speed increase when calling a sub through a pointer rather than a name? Why not just do:
sub fibo { my $inp = shift; $inp > 2 ? &fibo($inp - 1) + &fibo($inp - 2) : 1 }
(for the sake of simplicity, this has been coded so that the nth term IS the nth term)

1) 1
2) 1
3) 2
4) 3

  • Comment on Re^3: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
  • Download Code