[Melbourne-pm] Driving a serial command line device with Perl
Sisyphus
sisyphus1 at optusnet.com.au
Mon Oct 9 19:21:06 PDT 2006
----- Original Message -----
From: "Daniel Pittman" <daniel at rimspace.net>
.
.
>
> When my DESTROY method was called, though, the reference to the expect
> object was always undef and, with debugging enabled, I could see that it
> was destroyed immediately prior to my DESTROY method being called.
>
Does your DESTROY method try to clean up the Expect object ? Expect will
call it's own DESTROY method on its own objects - your DESTROY should not do
that.
Here's a silly demo - don't know if it helps:
---------------------
use warnings;
package EG;
sub DESTROY {print "EG exterminating $_[0]\n"}
package EXAMPLE;
for(1..5) {
print "\nStarting loop $_\n";
my $r = $_;
my $z = \$r;
bless $z, 'EG';
my $z_ref = \$z;
bless $z_ref, 'EXAMPLE';
}
print "\nFinished the for loop\n";
sub DESTROY {print "EXAMPLE exterminating $_[0]\n"}
--------------------
Outputs:
-------------------
Starting loop 1
EXAMPLE exterminating EXAMPLE=REF(0x8c5894)
EG exterminating EG=SCALAR(0x8c58ac)
Starting loop 2
EXAMPLE exterminating EXAMPLE=REF(0x3f5148)
EG exterminating EG=SCALAR(0x8c5894)
Starting loop 3
EXAMPLE exterminating EXAMPLE=REF(0x8c58ac)
EG exterminating EG=SCALAR(0x3f5148)
Starting loop 4
EXAMPLE exterminating EXAMPLE=REF(0x8c5894)
EG exterminating EG=SCALAR(0x8c58ac)
Starting loop 5
EXAMPLE exterminating EXAMPLE=REF(0x3f5148)
EG exterminating EG=SCALAR(0x8c5894)
Finished the for loop
-------------------
Cheers,
Rob
More information about the Melbourne-pm
mailing list