File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ of calling the C<open> function -- this time with the C<:w> (write) option
43
43
$fh.print("data and stuff\n");
44
44
$fh.close;
45
45
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
+
46
52
We can simplify this by using C < spurt > to open the file in write mode,
47
53
writing the data to the file and closing it again for us:
48
54
@@ -60,7 +66,13 @@ handle explicitly,
60
66
$fh.print("more data\n");
61
67
$fh.close;
62
68
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 > :
64
76
65
77
spurt "testfile", "more data\n", :append;
66
78
You can’t perform that action at this time.
0 commit comments