http://qs1969.pair.com?node_id=403538


in reply to Re: Functional Programming & method rewriting
in thread Functional Programming & method rewriting

Yep, good explanation. To add some further confusion (or perhaps to explain the shift trick), if I change around the last few lines and the functions will actually take arguments ...

my $hi_mom = prefix_later( sub { my $f = shift(); print "got: $f\n"; }, sub { print "this was unneccessary:\n"; } ); $hi_mom->("nerp") for (1..3);

Output:

got: nerp this was unneccessary: got: nerp this was unneccessary: got: nerp