Template Toolkit (and several other modules) use this idiom: sub new { my $class = shift;
# allow hash ref as first argument, otherwise fold args into hash my $config = defined $_[0] && UNIVERSAL::isa($_[0], 'HASH') ? shift : { @_ }; .. } Which lets you do any of these: my $foo = Foo->new(ONE => 1, TWO => 2); my $bar = Foo->new({ONE => 1, TWO => 2}); my $baz = Foo->new(\%opts); This is very convenient for when you've got a large hashref of options and don't want to unroll it for passing to a method. -- (darren)