Closed p5pRT closed 20 years ago
The short program below leaks under various versions of perl and on various OS. Am I missing something\, or is this a bug in perl?
Thanks!
$x="TST00000"; while(1) { my $handle=$x++; open($handle\,'/etc/rc'); # or any other file close($handle); }
On 31 Jan 2000 07:46:24 GMT\, gerti@bitart.com wrote:
The short program below leaks under various versions of perl and on various OS. Am I missing something\, or is this a bug in perl?
Thanks!
$x="TST00000"; while(1) { my $handle=$x++; open($handle\,'/etc/rc'); # or any other file close($handle); }
You're filling up the symbol table with empty symbols (closed filehandles). Create anonymous symbols with Symbol instead.
use Symbol; while (1) { open(my $handle = gensym\, '/etc/rc') or die; close $handle; }
In 5.6\, you'll be able to shorten that to:
while (1) { open my $handle\, '/etc/rc' or die; close $handle; }
Sarathy gsar@ActiveState.com
Migrated from rt.perl.org#2058 (status was 'resolved')
Searchable as RT2058$