sub new { my ($class, %arg) = @_; my $self = { table => $arg{table} || 'test', message => $arg{message}, dbh => MyDatabase::DBManager::connect(), cookie_name => $cookie_name, # other similar stuff here }; _login_user($self); return bless $self, $class; } sub _login_user { my $self = shift; # do something to log the user in based on $self->{cookie_name}, # returning $sess_ref as a reference to a db-stored session; then: if (!defined($sess_ref)) { print CGI::redirect(-uri=>'login.cgi'); } # i.e. if there's no session, bounce the user straight to a # login page, thus leaving in the middle of the constructor, # before hitting the "bless" else { # $sess_ref is defined, store some session info into # $self and get on with life, returning to "new" and to the # original program that called this module } }