Quick Tip #14: Myriad output routines

Perl 6 has many ways to output things. Here’s a table of the various routines you may want, along with their subtle differences.

routine   IO handle   Behavior  
print $*OUT
printf IO::Handle object Call as a method on some IO::Handle object.  
put $*OUT Outputs its arguments and adds the line-ending
say $*OUT Adds newline, uses .gist on non-Str objects
note $*ERR Adds newline, uses .gist on non-Str objects
dd $*ERR Rakudo extension for data dumping. It actually wraps warn.
prompt $*OUT Outputs arguments, then waits for a line of input. It returns the line without the newline.
die $*ERR Throws an exception. The default handler prints a stacktrace to standard error.
warn Throws an exception. You properly might want note instead.

Leave a Reply

Your email address will not be published. Required fields are marked *