I presume this was asked before I moved the brace, but even then no. The scalar would have (which is why I made the correction), but the subroutine sticks around (they're not lexically declared). Had I done this:
{ my $returned_data = []; my $callback = sub { push @{ $returned_data }, $_[0] }; } something_wanting_callback( $callback );
Then yes, that coderef would have gone out of scope.
In reply to Re^3: Why callbacks?
by Fletch
in thread Why callbacks?
by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |