my %hash; sub test{ my $obj = Test::class->new('bla1'=>'test','bla2'=>'test2'); $hash{$obj}=1; }