Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mention IO::Handle.say() as alternative to .print
  • Loading branch information
Paul Cochrane committed Feb 24, 2015
1 parent 2a0049a commit 1091feb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Language/io.pod
Expand Up @@ -43,6 +43,12 @@ of calling the C<open> function -- this time with the C<:w> (write) option
$fh.print("data and stuff\n");
$fh.close;
Or equivalently with C<say>, thus the explicit newline is no longer necessary:
my $fh = open "testfile", :w;
$fh.say("data and stuff");
$fh.close;
We can simplify this by using C<spurt> to open the file in write mode,
writing the data to the file and closing it again for us:
Expand All @@ -60,7 +66,13 @@ handle explicitly,
$fh.print("more data\n");
$fh.close;
or with the C<:append> option in the call to C<spurt>:
or equivalently with C<say>, thus the explicit newline is no longer necessary,
my $fh = open "testfile", :a;
$fh.say("more data");
$fh.close;
or even simpler with the C<:append> option in the call to C<spurt>:
spurt "testfile", "more data\n", :append;
Expand Down

0 comments on commit 1091feb

Please sign in to comment.