On Fri, 28 Jan 2005 11:38:51 -0700, Luke Palmer <[EMAIL PROTECTED]> wrote:
> I don't think it's the cleanest solution, but it works.
Just out of curiosity, what do you think would be a cleaner solution?
And why would one not want to implement such a solution instead?
// Carl
On Fri, 28 Jan 2005 11:38:51 -0700, Luke Palmer <[EMAIL PROTECTED]> wrote:
> Juerd writes:
> > Luke Palmer skribis 2005-01-28 9:31 (-0700):
> > > > And can $_ be used instead of $^n?
> > > Of course it can. You know that.
> >
> > I do?
> >
> > Can't say I understand well when a topic is implicitly defined and when
> > not. It's obvious for for-loops and given, but everything else is
> > blurry to me.
>
> Okay, I'll explain then. If you use $_ inside a closure, then it is
> assumed to mean an argument to that closure. If the closure isn't given
> an argument (or the block is declared to have zero arguments at compile
> time) then $_ defaults to the outer lexical $_, which fixes this
> problem:
>
> for @stuff {
> if something() {
> print; # prints the argument to if's block
> }
> }
>
> I don't think it's the cleanest solution, but it works.
>
> Luke
>