my %args = ( foo => 1, bar => 2 ); my $class = $type == 0 ? ClassA->new( %args ) : $type == 1 ? ClassB->new( %args ) : 'ClassC';