in reply to •Re: One liner to Check and undef hash elements
in thread One liner to Check and undef hash elements

Nice! I knew there had to be a better way. Regarding problem 1, what exactly does ->() do? I know that without it, a coderef would be returned, and with it, the result is returned. But how does it work? Does it evaluate the sub on the spot or in the moment I access $hash_has_non_undef?

Replies are listed 'Best First'.
•Re: Re: •Re: One liner to Check and undef hash elements
by merlyn (Sage) on Apr 16, 2003 at 11:08 UTC
Re^3: One liner to Check and undef hash elements ( sub { .. }->() explained)
by Aristotle (Chancellor) on Apr 16, 2003 at 11:20 UTC
    sub { ... } as an expression returns a reference to an anonymous function. ->(@list); takes a reference to an anonymous function and calls it. So what happens when you chain them is you define an anonymous function and call it on the spot, the anonymous function being lost, because you didn't save the reference anywhere.

    Makeshifts last the longest.