octothorpe has asked for the wisdom of the Perl Monks concerning the following question:
To provide context, a more realistic usage might involve computing a factorial.use strict; # leak occurs whether strict is used or not while(1) { &leak(); } sub leak { my $sub_ref; $sub_ref = sub { &$sub_ref(); }; return 0; }
Additional context: this problem originally occured for me in a recursive descent parser, which had a whole lot of tiny functions I wanted to obscure from UltraEdit's function list. Is this a Perl bug? If so, where can I find more information about its status?sub leak { my $factorial_sub_ref; $factorial_sub_ref = sub { my ($number) = @_; if ($number < 2) { return 1; } return($number + &$factorial_sub_ref($number - 1)); }; return 0; }
|
|---|