package Food::Product; use strict; use LEOCHARRE::Class2; # you do this your way use vars qw/$errstr/; __PACKAGE__->make_accessor_setget(qw/isle stock errst/); sub new { my($class,$arg)=@_; $arg or $errstr = "Missing valid arg" and return; return { name => $arg }, $class; } sub sell { my($self,$count)=@_; $count or $self->errstr('missing how much to sell ammount') and return; my $now = $self->stock or $self->errstr('no stock left to sell from') and return; my $left_over = ( $now - $count ) ... some other rationalle $self->stock($left_over); }