Jump to content

Hello world/Line printer: Difference between revisions

→‎{{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.
(→‎{{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:
 
=={{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 {
.say: 'Hello World!';
.close;
}</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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.