use v5.38;
use feature 'class';
no warnings 'experimental::class';

class Hello {
 field $x :param;

 method hello_twice {
  say "Hello! $x";
 }
}

Hello->new(x => 123)->hello_twice;
Hello->new(x => 'abc')->hello_twice;



実行結果
$ perl hello_twice.txt
Hello! 123
Hello! abc