Skip to content

Commit 1091feb

Browse files
committed
Mention IO::Handle.say() as alternative to .print
1 parent 2a0049a commit 1091feb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/Language/io.pod

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ of calling the C<open> function -- this time with the C<:w> (write) option
4343
$fh.print("data and stuff\n");
4444
$fh.close;
4545
46+
Or equivalently with C<say>, thus the explicit newline is no longer necessary:
47+
48+
my $fh = open "testfile", :w;
49+
$fh.say("data and stuff");
50+
$fh.close;
51+
4652
We can simplify this by using C<spurt> to open the file in write mode,
4753
writing the data to the file and closing it again for us:
4854
@@ -60,7 +66,13 @@ handle explicitly,
6066
$fh.print("more data\n");
6167
$fh.close;
6268
63-
or with the C<:append> option in the call to C<spurt>:
69+
or equivalently with C<say>, thus the explicit newline is no longer necessary,
70+
71+
my $fh = open "testfile", :a;
72+
$fh.say("more data");
73+
$fh.close;
74+
75+
or even simpler with the C<:append> option in the call to C<spurt>:
6476
6577
spurt "testfile", "more data\n", :append;
6678

0 commit comments

Comments
 (0)