๐Ÿ“˜ How to debug Perl 6 programs

For quick tests, use the compiler in the mode of the REPL (readโ€”evalโ€”print loop) shell. Just run theย perl6 command:

$ perl6
To exit type 'exit' or '^D'

With bigger programs, one of the following techniques helps to visualise data:

1. Theย say routine is used as a stand-alone function or as an object method. It works well with both scalar and aggregate data, such as arrays, hashes, or objects:

say $x;
%data.say;

2. Theย perl method, which returns the representation of an object in the Perlย 6 syntax:

say {a => 1, b => 2}.perl; # {:a(1), :b(2)}

3. The WHAT and the ^name methods, which give you the information about the object type or class name:

my Int $x;
say $x.WHAT;  # (Int)
say $x.^name; # Int

4. Theย dd routine. This is a Rakudo-specific feature that dumps an object:

my @a = 1..5;
dd @a; # Array @a = [1, 2, 3, 4, 5]