blazar has asked for the wisdom of the Perl Monks concerning the following question:
Now, I'm sure some one will mention that I can domy sub foo { # ... }
instead. And yes, of course I knew, but even if we don't feel an extreme need for lexically scoped named subs it wouldn't be too bad to have them either. Maybe they may go into 5.10, couldn't they?my $foo = sub { ... };
Thus we may have something like this:
This is of course an oversimplified and probably not extremely appropriate example, but I hope it gives an idea...sub invert { my ($n, $p)=@_; # Trusting $p to be a prime... my sub expp { my ($n, $m)=@_; return 1 unless $m; ($m%2 ? $n : 1) * expp($n, $m >> 1)**2 % $p; } expp($n, $p-2); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Isn't Perl5 ready for C<my sub>?
by merlyn (Sage) on Sep 07, 2005 at 14:55 UTC | |
by friedo (Prior) on Sep 07, 2005 at 16:48 UTC | |
by blazar (Canon) on Sep 07, 2005 at 15:26 UTC | |
|
Re: Isn't Perl5 ready for C<my sub>?
by dave_the_m (Monsignor) on Sep 07, 2005 at 16:00 UTC | |
by blazar (Canon) on Sep 08, 2005 at 14:17 UTC | |
by dave_the_m (Monsignor) on Sep 08, 2005 at 14:46 UTC |