my $foo = Foo::Bar->new(name => 'blah', system => 'linux'); sub new { my $pkg = shift; my $self; { my %hash; $self = bless(\%hash, $pkg); } # setup an options hash my $options = {}; $self->{options} = $options; # set options hash's defaults %$options = ( logType => "both", fileSize => 100000000, fileExt => ".log", filePath => "/tmp/", fileName => $log->{filePath} . $report . $log->{fileExt}, fileCount => 3, dbAgeSize => 1, dbAgeUnit => "DAY", dbConnStr => 'dbi:mysql:reports:localhost', dbUser => "user", dbPasswd => "*******", status => "testing", entry => "", 'system' => "none", #system's a keyword though, so might rename name => "default", ); # load in options supplied to new() for (my $i = 0; $i <= $#_; $i += 2) { defined($_[($i + 1)]) or croak("odd number of options, should be in option => value form"); $options->{lc($_[$i])} = $_[($i + 1)]; } ###possibly several more steps to test other options here return $self; }