Skip to content

Commit e275469

Browse files
author
Jan-Olof Hendig
committed
Some formatting adjustments
1 parent 9a369c7 commit e275469

File tree

1 file changed

+103
-103
lines changed

1 file changed

+103
-103
lines changed

doc/Type/IO/Handle.pod6

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
Defined as:
1414
1515
=for code :skip-test
16-
method open(IO::Handle:D:
17-
:$bin, :$enc, :$chomp, :$nl-in, Str:D :$nl-out,
18-
Str :$mode,
19-
:$r, :$w, :$a, :$x, :$update, :$rw, :$rx, :$ra,
20-
:$create, :$append, :$truncate, :$exclusive,
21-
--> IO::Handle:D
22-
)
16+
method open(IO::Handle:D:
17+
:$bin, :$enc, :$chomp, :$nl-in, Str:D :$nl-out,
18+
Str :$mode,
19+
:$r, :$w, :$a, :$x, :$update, :$rw, :$rx, :$ra,
20+
:$create, :$append, :$truncate, :$exclusive,
21+
--> IO::Handle:D
22+
)
2323
2424
Opens the handle in one of the modes. L<Fails|/routine/fail> with appropriate
2525
exception if the open fails.
@@ -40,16 +40,16 @@ The open mode defaults to non-exclusive, read only (same as specifying
4040
C<:r>) and can be controlled by a mix of the following arguments:
4141
4242
=begin code :skip-test :allow< B R >
43-
:r same as specifying :mode<ro>
43+
:r same as specifying :mode<ro>
4444
45-
:w same as specifying :mode<wo>, :create, :truncate
46-
:a same as specifying :mode<wo>, :create, :append
47-
:x same as specifying :mode<wo>, :create, :exclusive
45+
:w same as specifying :mode<wo>, :create, :truncate
46+
:a same as specifying :mode<wo>, :create, :append
47+
:x same as specifying :mode<wo>, :create, :exclusive
4848
49-
:update same as specifying :mode<rw>
50-
:rw same as specifying :mode<rw>, :create
51-
:ra same as specifying :mode<rw>, :create, :append
52-
:rx same as specifying :mode<rw>, :create, :exclusive
49+
:update same as specifying :mode<rw>
50+
:rw same as specifying :mode<rw>, :create
51+
:ra same as specifying :mode<rw>, :create, :append
52+
:rx same as specifying :mode<rw>, :create, :exclusive
5353
=end code
5454
5555
Support for combinations of modes I<other> than what is listed above
@@ -61,14 +61,14 @@ to implode, depending on a particular implementation.
6161
The mode details are:
6262
6363
=begin code :skip-test :allow< B R >
64-
:mode<ro> means "read only"
65-
:mode<wo> means "write only"
66-
:mode<rw> means "read and write"
67-
68-
:create means the file will be created, if it does not exist
69-
:truncate means the file will be emptied, if it exists
70-
:exclusive means .open will fail if the file already exists
71-
:append means writes will be done at the end of file's current contents
64+
:mode<ro> means "read only"
65+
:mode<wo> means "write only"
66+
:mode<rw> means "read and write"
67+
68+
:create means the file will be created, if it does not exist
69+
:truncate means the file will be emptied, if it exists
70+
:exclusive means .open will fail if the file already exists
71+
:append means writes will be done at the end of file's current contents
7272
=end code
7373
7474
Attempts to open a directory, write to a handle opened in read-only mode
@@ -135,13 +135,13 @@ L<in binary mode|/type/IO::Handle#method_encoding> will result in
135135
C<X::IO::BinaryMode> exception being thrown.
136136
137137
=begin code
138-
$*IN.get.say; # Read one line from the standard input
138+
$*IN.get.say; # Read one line from the standard input
139139
140-
my $fh = open 'filename';
141-
$fh.get.say; # Read one line from a file
142-
$fh.close;
140+
my $fh = open 'filename';
141+
$fh.get.say; # Read one line from a file
142+
$fh.close;
143143
144-
say get; # Read one line from $*ARGFILES
144+
say get; # Read one line from $*ARGFILES
145145
=end code
146146
147147
=head2 routine getc
@@ -200,8 +200,8 @@ L«C<.path>|/type/IO::Handle#method_path», if any, the handle is created for
200200
and whether it is L«C<.opened>|/type/IO::Handle#method_opened».
201201
202202
=begin code
203-
say IO::Handle.new; # IO::Handle<(Any)>(closed)
204-
say "foo".IO.open; # IO::Handle<"foo".IO>(opened)
203+
say IO::Handle.new; # IO::Handle<(Any)>(closed)
204+
say "foo".IO.open; # IO::Handle<"foo".IO>(opened)
205205
=end code
206206
207207
=head2 method eof
@@ -231,12 +231,12 @@ vary by implementation and backend. On Rakudo MoarVM the following are
231231
supported:
232232
233233
=for code :skip-test
234-
utf8
235-
utf16
236-
utf8-c8
237-
iso-8859-1
238-
windows-1252
239-
ascii
234+
utf8
235+
utf16
236+
utf8-c8
237+
iso-8859-1
238+
windows-1252
239+
ascii
240240
241241
The default encoding is utf8, which undergoes normalization into Unicode B<NFC>
242242
(normalization form canonical). In some cases you may want to ensure no
@@ -249,13 +249,13 @@ allows aliases C<latin-1> for C<iso-8859-1> encoding and dashed utf versions:
249249
C<utf-8> and C<utf-16>.
250250
251251
=begin code
252-
with 'foo'.IO {
253-
.spurt: "First line is text, then:\nBinary";
254-
my $fh will leave {.close} = .open;
255-
$fh.get.say; # OUTPUT: «First line is text, then:␤»
256-
$fh.encoding: Nil;
257-
$fh.slurp.say; # OUTPUT: «Buf[uint8]:0x<42 69 6e 61 72 79>␤»
258-
}
252+
with 'foo'.IO {
253+
.spurt: "First line is text, then:\nBinary";
254+
my $fh will leave {.close} = .open;
255+
$fh.get.say; # OUTPUT: «First line is text, then:␤»
256+
$fh.encoding: Nil;
257+
$fh.slurp.say; # OUTPUT: «Buf[uint8]:0x<42 69 6e 61 72 79>␤»
258+
}
259259
=end code
260260
261261
=head2 routine lines
@@ -288,10 +288,10 @@ when you close the handle or attempt to use any other methods that change the
288288
file position.
289289
290290
=begin code
291-
say "The file contains ",
292-
'50GB-file'.IO.open.lines.grep(*.contains: 'Perl').elems,
293-
" lines that mention Perl";
294-
# OUTPUT: «The file contains 72 lines that mention Perl␤»
291+
say "The file contains ",
292+
'50GB-file'.IO.open.lines.grep(*.contains: 'Perl').elems,
293+
" lines that mention Perl";
294+
# OUTPUT: «The file contains 72 lines that mention Perl␤»
295295
=end code
296296
297297
=head2 method lock
@@ -515,11 +515,11 @@ This method can be called even when the handle is not
515515
L<in binary mode|/type/IO::Handle#method_encoding>.
516516
517517
=begin code
518-
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
519-
given $file.open {
520-
say .read: 6; # OUTPUT: «Buf[uint8]:0x<49 20 e2 99 a5 20>␤»
521-
.close;
522-
}
518+
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
519+
given $file.open {
520+
say .read: 6; # OUTPUT: «Buf[uint8]:0x<49 20 e2 99 a5 20>␤»
521+
.close;
522+
}
523523
=end code
524524
525525
=head2 method readchars
@@ -536,11 +536,11 @@ L<in binary mode|/type/IO::Handle#method_encoding> will result in
536536
C<X::IO::BinaryMode> exception being thrown.
537537
538538
=begin code
539-
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
540-
given $file.open {
541-
say .readchars: 5; # OUTPUT: «I ♥ P␤»
542-
.close;
543-
}
539+
(my $file = 'foo'.IO).spurt: 'I ♥ Perl';
540+
given $file.open {
541+
say .readchars: 5; # OUTPUT: «I ♥ P␤»
542+
.close;
543+
}
544544
=end code
545545
546546
=head2 method write
@@ -628,15 +628,15 @@ parameter and C<65536> bytes in binary mode or C<65536> characters in non-binary
628628
mode.
629629
630630
=for code
631-
"foo".IO.open(:bin).Supply(:size<10>).tap: *.perl.say;
632-
# OUTPUT:
633-
# Buf[uint8].new(73,32,226,153,165,32,80,101,114,108)
634-
# Buf[uint8].new(32,54,33,10)
631+
"foo".IO.open(:bin).Supply(:size<10>).tap: *.perl.say;
632+
# OUTPUT:
633+
# Buf[uint8].new(73,32,226,153,165,32,80,101,114,108)
634+
# Buf[uint8].new(32,54,33,10)
635635
636-
"foo".IO.open.Supply(:size<10>).tap: *.perl.say;
637-
# OUTPUT:
638-
# "I ♥ Perl 6"
639-
# "!\n"
636+
"foo".IO.open.Supply(:size<10>).tap: *.perl.say;
637+
# OUTPUT:
638+
# "I ♥ Perl 6"
639+
# "!\n"
640640
641641
642642
=head2 method path
@@ -666,7 +666,7 @@ Returns the value of L«C<.path>|/type/IO::Handle#method_path», coerced
666666
to L<Str>.
667667
668668
=for code
669-
say "foo".IO.open.path; # OUTPUT: «"foo".IO␤»
669+
say "foo".IO.open.path; # OUTPUT: «"foo".IO␤»
670670
671671
=head2 routine close
672672
@@ -683,26 +683,26 @@ closing the handles, which ensures the handle is closed regardless of how the
683683
block is left.
684684
685685
=begin code :skip-test
686-
if $do-stuff-with-the-file {
687-
my $fh = open "path-to-file";
688-
LEAVE close $fh;
689-
# ... do stuff with the file
690-
}
686+
if $do-stuff-with-the-file {
687+
my $fh = open "path-to-file";
688+
LEAVE close $fh;
689+
# ... do stuff with the file
690+
}
691691
692-
sub do-stuff-with-the-file (IO $path-to-file)
693-
my $fh = $path-to-file.open;
692+
sub do-stuff-with-the-file (IO $path-to-file)
693+
my $fh = $path-to-file.open;
694694
695-
# stick a `try` on it, since this will get run even when the sub is
696-
# called with wrong arguments, in which case the `$fh` will be an `Any`
697-
LEAVE try close $fh;
695+
# stick a `try` on it, since this will get run even when the sub is
696+
# called with wrong arguments, in which case the `$fh` will be an `Any`
697+
LEAVE try close $fh;
698698
699-
# ... do stuff with the file
700-
}
699+
# ... do stuff with the file
700+
}
701701
702-
given "foo/bar".IO.open(:w) {
703-
.spurt: "I ♥ Perl 6!";
704-
.close;
705-
}
702+
given "foo/bar".IO.open(:w) {
703+
.spurt: "I ♥ Perl 6!";
704+
.close;
705+
}
706706
=end code
707707
708708
B<Note:> unlike some other languages, Perl 6 does not use reference counting,
@@ -729,13 +729,13 @@ Will flush the handle, writing any of the buffered data. Returns C<True>
729729
on success; otherwise, L<fails|/routine/fail> with C<X::IO::Flush>.
730730
731731
=begin code :skip-test
732-
given "foo".IO.open: :w {
733-
LEAVE .close;
734-
$fh.print: 'something';
735-
'foo'.IO.slurp.say; # (if the data got buffered) OUTPUT: «␤»
736-
$fh.flush; # flush the handle
737-
'foo'.IO.slurp.say; # OUTPUT: «something␤»
738-
}
732+
given "foo".IO.open: :w {
733+
LEAVE .close;
734+
$fh.print: 'something';
735+
'foo'.IO.slurp.say; # (if the data got buffered) OUTPUT: «␤»
736+
$fh.flush; # flush the handle
737+
'foo'.IO.slurp.say; # OUTPUT: «something␤»
738+
}
739739
=end code
740740
741741
=head2 method native-descriptor
@@ -762,12 +762,12 @@ in routines that C<chomp>, such as L«C<get>|/routine/get» and
762762
L«C<lines>|/routine/lines».
763763
764764
=begin code
765-
with 'test'.IO {
766-
.spurt: '1foo2bar3foo'; # write some data into our test file
767-
my $fh will leave {.close} = .open; # can also set .nl-in via .open arg
768-
$fh.nl-in = [<foo bar>]; # set two possible line endings to use;
769-
$fh.lines.say; # OUTPUT: ("1", "2", "3").Seq
770-
}
765+
with 'test'.IO {
766+
.spurt: '1foo2bar3foo'; # write some data into our test file
767+
my $fh will leave {.close} = .open; # can also set .nl-in via .open arg
768+
$fh.nl-in = [<foo bar>]; # set two possible line endings to use;
769+
$fh.lines.say; # OUTPUT: ("1", "2", "3").Seq
770+
}
771771
=end code
772772
773773
=head2 method nl-out
@@ -782,15 +782,15 @@ handle, to be used by methods L«C<.put>|/type/IO::Handle#method_put»
782782
and L«C<.say>|/type/IO::Handle#method_say».
783783
784784
=begin code
785-
with 'test'.IO {
786-
given .open: :w {
787-
.put: 42;
788-
.nl-out = 'foo';
789-
.put: 42;
790-
.close;
791-
}
792-
.slurp.perl.say; # OUTPUT: «"42\n42foo"»
785+
with 'test'.IO {
786+
given .open: :w {
787+
.put: 42;
788+
.nl-out = 'foo';
789+
.put: 42;
790+
.close;
793791
}
792+
.slurp.perl.say; # OUTPUT: «"42\n42foo"»
793+
}
794794
=end code
795795
796796
=head2 method opened

0 commit comments

Comments
 (0)