#!/usr/bin/perl use strict; use warnings FATAL => qw(all); { package test; use IO::Socket::INET; our @ISA = ('IO::Socket::INET'); my %field; sub new { my $class = shift; my $self = $class->SUPER::new ( PeerAddr => '127.0.0.1:80', Proto => 'tcp', Blocking => 0 ); $field{$self} = pop; return $self; } sub getField { my $self = shift; return $field{$self}; } sub DESTROY { my $self = shift; delete $field{$self}; $self->SUPER::DESTROY(); print STDERR "Bye!\n"; } 1; } my $obj = test->new("okay"); print $obj->getField."\n"; print $obj->sockhost."\n"; my $two = test->new("two"); print $two->getField."\n";