package Foo; my %DEFAULTS= ( NAME=>'', USERNAME=>'', ); sub new { my($pkg,%rest)=(@_); if(ref($pkg)) { #called as $instance->new() #do something about this. ; } # Checks, maybe? and other stuff. # this overwrites the stuff in %DEFAULTS with the stuff in # in %rest, if applicable. bless { (%DEFAULTS,%rest) }, $pkg; } ## #Main ## my $foo=Foo->new(); # gets blank NAME, USERNAME my $bar=Foo->new(NAME=>'bar', USERNAME=>'baz'); print STDOUT "Your mileage WILL vary\n";