use v5.12; { package Point; use Moose; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); around BUILDARGS => sub { my $orig = shift; my $self = shift; # Allow object to be built by passing two integers... if (@_ == 2 and $_[0] =~ /^[0-9]+$/ and $_[1] =~ /^[0-9]+$/) { return { x => $_[0], y => $_[1] }; } # If not two integers, then fall back to standard Moose BUILDARGS... return $self->$orig(@_); }; __PACKAGE__->meta->make_immutable; } # Use our overridden BUILDARGS... print Point->new(10, 20)->dump; # Standard Moose BUILDARGS is fallback... print Point->new(x => 10, y => 20)->dump; print Point->new({ x => 10, y => 20 })->dump;