in reply to Re^5: Inheritance and objects tied to a database
in thread Inheritance and objects tied to a database
use strict; use warnings; use Data::Dumper; my $control = Control->new(); my $app = Control::Main->new( %{$control} ); package Control; use Data::Dumper; sub new { my $class = shift; my $self = bless {}, ref($class) || $class; #my $dbh = Area::DB::connect(\$_connected) if !$_connected; #tie %{$self->{data}}, "Tie::ODBCSession", $dbh, $session_id; $self->{data} = {}; return $self; } sub DESTROY { my $self = shift; print "Destroying parent:\n"; print Dumper ($self) . "\n"; } package Control::Main; @Control::Main::ISA = qw(Control); use Data::Dumper; sub new { my $class = shift; my %args = @_; my $self = {}; bless $self, $class; # initialize with named parameters passed %{$self} = map { $_ => $args{$_} } keys(%args); # store action in the object $self->{data}->{action} = "test"; return $self; } sub DESTROY { my $self = shift; $self->{data} = undef; print "Destroying child:\n"; print Dumper ($self) . "\n"; }
|
|---|