wantarray(2)

Ovid on 2007-10-07T14:35:40

I want to be able to do this:

if ( wantarray(2) ) { ... }

Like caller, you could specify how many frames back you want to test. I find I need that at times when I'm refactoring. wantarray doesn't allow you to do this. However, in looking at the Want module, I've discovered that there is an undocumented function called want_uplevel. This may be exactly what I need!


caller()

chromatic on 2007-10-07T16:29:34

You can use (caller[2])[5], though it's not nearly as self-documenting.

Re:caller()

Ovid on 2007-10-07T16:32:56

D'oh! That's particularly embarrassing since I'm the author of Perl6::Caller and should know how it works :)