npf has asked for the wisdom of the Perl Monks concerning the following question:
I indeed notice that the output result changes between perl 5.6.1:#!/usr/bin/perl -w use strict; use warnings; use Error qw(:try); for (1..3) { my $x = Foo->new(); try { try { print "$_: $x\n" }; }; } END { warn("interpreter exit\n") } package Foo; sub new { return bless {}, shift } sub DESTROY { warn("Foo::DESTROY\n") }
and Perl 5.10.0:1: Foo=HASH(0x80f6084) 2: Foo=HASH(0x813b750) 3: Foo=HASH(0x815a0f0) interpreter exit Foo::DESTROY Foo::DESTROY Foo::DESTROY
The object seems indeed destroyed when leaving the loop's scope.1: Foo=HASH(0x81981f8) Foo::DESTROY 2: Foo=HASH(0x81981f8) Foo::DESTROY 3: Foo=HASH(0x81981f8) Foo::DESTROY interpreter exit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error.pm vs closure issue fixed in Perl > 5.8.4 ?
by perrin (Chancellor) on Sep 02, 2008 at 01:37 UTC | |
by tye (Sage) on Sep 02, 2008 at 20:42 UTC | |
by perrin (Chancellor) on Sep 02, 2008 at 21:37 UTC |