package Foo; sub new { my $arg = shift; my $class = ref($arg) || $arg; # finally some use for this cargo-cult thing :) print "creating object of type $class\n"; return bless {}, $class; } package main; use strict; use warnings; my $new = bless \&Foo::new, "Foo"; # code object # and then one of: my $obj; $obj = $new->(ref($new)); # passes "Foo" $obj = $new->($new); # passes code object of type Foo $obj = $new->new(); # passes code object of type Foo $obj = $new->$new(); # passes code object of type Foo