package Item; $VERSION = 1.0; use strict; use Class::MethodMaker new_with_init => 'new', new_hash_init => '_init_args', static_hash => 'counter', get_set => [qw( sku qty )]; sub count { $_[0]->counter('count') } sub _incr_count { $_[0]->counter(count=>$_[0]->counter('count')+1) } sub _decr_count { $_[0]->counter(count=>$_[0]->counter('count')-1) } sub init { my ($self, %args) = @_; $self->_init_args(%args); $self->_incr_count(); return $self; } sub DESTROY { $_[0]->_decr_count(); } package Info; $VERSION = 1.0; use strict; use Apache::Session::MySQL; use Class::MethodMaker "-sugar"; make methods new_with_init => 'new', object_list => [ Items => 'items' ], get_set => [qw( orderid )]; sub timestamp { $_[0]->{_timestamp} = time() } sub cid { $_[0]->{_session_id} } sub init { my ($self, %args) = @_; tie %{ $self }, 'Apache::Session::MySQL', $args{cid}, { DataSource => 'dbi:mysql:ssdw_store', UserName => 'web', Password => 'webpass1', LockDataSource => 'dbi:mysql:ssdw_store', LockUserName => 'web', LockPassword => 'webpass1', }; $self->timestamp; return $self; } sub DESTROY { $_[0]->timestamp; untie %{$_[0]}; } 1;