class MyFormat is CORE::GrammarVisitor { my $fh is public; method date ($node) { $fh.printf("%04d-%02d-%02d", $node ^. qw(year month day)) } } $0.traverse(MyFormat.new(fh=>$*STDOUT)); # default ctor?