use 5.37.9; no warnings qw( experimental ); use feature qw( class defer ); use builtins qw( true false ); class No::New { use Carp; my $allow_construction = false; ADJUST { croak "Directly calling @{[ __PACKAGE__ ]}->new is forbidden" unless $allow_construction; } sub create { my $class = shift; $allow_construction = true; defer { $allow_construction = false }; return $class->new; } method text { "Congratulations!"; } } say No::New->create->text;