my $obj = {}; # empty anonymous hash reference
bless $obj, "Some::Class";
####
package Some::Class;
my $obj = {};
bless $obj; # blesses into "Some::Class"
####
$obj->method( 'foo' ); # @_ contains ( $obj, 'foo' )
Some::Class->method( 'foo' ); # @_ contains ( 'Some::Class', 'foo' )
####
package Some::Class;
sub new {
my $first_arg = shift; # get the first argument
my $class = ref($first_arg) || $first_arg;
my $self = {}; # create a new, anonymous reference;
bless $self, $class: # bless it into the class
return $self;
}