package Widget; use strict; use warnings; # generic constructor, allows for any keys to be passed like, # my $widget = Widget->new(field1 => "value 1", field2 => "value 2", etc => "etc..."); sub new { my ($pkg, %self) = @_; # can validate parameters here... (I like Validate::Tiny) # technically it's a "package", also the 2nd argument to # bless is a string, literally just the "package" name ('Widget') return bless \%self, $pkg; } 1; #<-- note