I would like to premise that I'm completely ignorant of current perls' internals. However in informal discussions people with much more experience and knowledge about it told me that the lexical pad is not much different from a common package. Now I wonder if it has a code slot too, or if one could easily be added if not, so as to allow for lexically scoped named subs too:
my sub foo { # ... }
Now, I'm sure some one will mention that I can do
my $foo = sub { ... };
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?

Thus we may have something like this:

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); }
This is of course an oversimplified and probably not extremely appropriate example, but I hope it gives an idea...

In reply to Isn't Perl5 ready for C<my sub>? by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.