Hello world/Line printer: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: pull the comments out of the code and make them less confusing/dubious)
(→‎{{header|Perl 6}}: on second thought, it's best to first show the simplest way, then the "clever" way doesn't even need much explanation.)
Line 534: Line 534:


=={{header|Perl 6}}==
=={{header|Perl 6}}==

<lang perl6>my $lp = open '/dev/lp0', :w;
$lp.say: 'Hello World!';
$lp.close;</lang>

Or using <code>given</code> to avoid having to write the variable name repeatedly:

<lang perl6>given open '/dev/lp0', :w {
<lang perl6>given open '/dev/lp0', :w {
.say: 'Hello World!';
.say: 'Hello World!';
.close;
.close;
}</lang>
}</lang>

<tt>open</tt> returns a handle.<br>
<tt>given</tt> sets the handle as the current 'topic' inside the block.<br>
Bare method calls operate on the current topic.


=={{header|Phix}}==
=={{header|Phix}}==