I think the most productive approach would be to
post test code, assuring your intentions are understood, such that other stop posting speculative code...
Anyway I doubt that your desired "my_local" (or better named "lex-local") is what you need, since $x,$y,$z will always also belong to the outer scope, making ugly side-effects probable!
{ #outer scope
$lamb = lambda ( $x, $y, $z ) => sub { $x + $y }
}
the following is simple and very close but lacks the same aliasing like $_[0] does.
$lamb = sub { my ($x,$y,$z) = @_; $x + $y }
so using Data::Alias or Lexical::Alias might be what you need to install for lexicals.
If you don't wanna install XS-Moduls try working with lex-refs
DB<20> $lamb=sub { my($x,$y)=\(@_); $$x += $$y }
DB<21> $a=10; $lamb->($a,5); print $a
15
NOTE: Aliasing can always be achieved with * and pack-vars.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.