$test->execute( { print "This is user code\n"; die "The devil is in $test->name()! I can't live with that!" if $test->IsDevilPresent(); } ); #### $test->execute( { my $self = shift; print "This is user code\n"; die "The devil is in $self->name()! I can't live with that!" if $self->IsDevilPresent(); } ); #In the package, you must supply $self as an arg: return &$coderef( $self );