You're calling "greet" as a method. Therefore it's getting passed the object ($obj) as its first parameter. But in the method you're assuming that the greeting is the first parameter. It's a simple fix.
sub greet { my($self, $grt) = @_ ; return sub { my($subject)= @_; print "$grt $subject \n"; }; }
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: How to implement closures in Package
by davorg
in thread How to implement closures in Package
by perlCrazy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |