in reply to Re^2: Fake a sub ref?
in thread Fake a sub ref?

Not true. It only requires a global instance of the object OR a pre-existing $someobj, not both.

Pre-existing:

sub create_closure { my ($obj) = @_; return sub { print($obj, $/); }; } my $sub; { my $existing_obj = 1234; my $sub = create_closure($existing_obj); } &$sub(); # Prints 1234, even though $existing_obj is out of scope.

Global:

our $global_obj; $global_obj = 1234; my $sub = sub { print($global_obj, $/); }; $global_obj = 5678; &$sub(); # Prints 5678.