use Hook::LexWrap 'wrap'; sub my_func { return ("foo") x shift } wrap my_func => post => sub { my $cnt = @{$_[-1]}; # assumes list context! print "Returning $cnt values\n"; }; print my_func(1), "\n"; print my_func(2), "\n"; print my_func(3), "\n"; __END__ Returning 1 values foo Returning 2 values foofoo Returning 3 values foofoofoo