# Pass this a CODE reference and any arguments you wish. sub do { # If we're passed a CODE reference, shift it out of the args and goto it. goto &{splice(@_, ARG0, 1)} if ref($_[ARG0]) eq 'CODE'; }
--coral
# Create a POE object that runs when the program exits. Useful for # auto-running POE scripts. sub DESTROY { # Did we get a blessed POE object? Can it run()? Do it! my $o = shift; $o->run() if ref($o) eq 'POE::Kernel'; }
--coral
sungo: you might want to check out msteven's excellent POE::Component::SubWrapper for a very robust and featureful implementation of this same idea.