<commit_before>=begin pod

=TITLE class IO::Handle

=SUBTITLE Opened file or stream

   class IO::Handle does IO { }

=head1 Methods

=head2 method get

Reads a single line from the input stream (usually the Standard Input or a file).

Read one line from the standard input:

    $*IN.get;

Read one line from a file:

    my $fh = open 'filename';
    my $line = $fh.get;


=head2 method getc

Read a single character from the input stream.

=head2 method eof

Returns L<Bool::True> if the read operations have exhausted the content of the file.

=head2 method lines

    method lines($limit = Inf)

Return a lazy list of the file's lines read via L<get>, limited to C<$limit> lines.

    =for code :allow<B>
    my @data;
    my $data-file = open 'readings.csv'
    for B<$data-file.lines> -> $line {
        @data.push($line.split(','))
    }

=head2 method words

    method words($count = Inf)

Return a lazy list of the file's words (separated on whitespace), limited
to C<$count> words.

    =for code :allow<B>
    my %dict;
    ++%dict{$_} for $*IN.words;
    say "Most common words: ", %dict.sort(*.value).reverse.[^5];

=head2 method split

    method split(splitter = "")

Returns a lazy list of strings found between the splitter, just like C<split>
on strings.

=head2 method comb

    method comb(comber = "")

Returns a lazy list of strings combed from the handle, just like C<comb>
on strings.

=head2 method print

    method print(*@text --> Bool)

Text writing; writes the given C<@text> to the filehandle.  See L<write>
to write bytes.

    my $fh = open 'path/to/file', :w;
    $fh.print("some text\n");
    $fh.close;

=head2 method read

    method read(IO::Handle:D: Int(Cool:D) $bytes --> Blob)

Binary reading; reads and returns up to C<$bytes> bytes from the filehandle.

=head2 method readchars

    method readchars(IO::Handle:D: Int(Cool:D) $chars --> Str)

Reading chars; reads and returns up to C<$chars> chars (graphemes) from the
filehandle.

=head2 method write

    method write(IO::Handle:D: Blob:D $buf)

Binary writing; writes C<$buf> to the filehandle.  See L<print> to write
characters.

=head2 method seek

     method seek(IO::Handle:D: Int:D $offset, Int:D $whence)

Move the file pointer (that is the position at which any subsequent read
or write operations will begin,) to the byte position specified by
C<$offset> relative to the location specified by C<$whence> which may be
one of:

=item 0

The beginning of the file.

=item 1

The current position in the file.

=item 2

The end of the file.

=head2 method tell

    method tell(IO::Handle:D: --> Int)

Return the current position of the file pointer in bytes.

=head2 method ins

    method ins(IO::Handle:D: --> Int)
<commit_msg>Update IO::Handle.seek parameters documentation<commit_after>=begin pod

=TITLE class IO::Handle

=SUBTITLE Opened file or stream

   class IO::Handle does IO { }

=head1 Methods

=head2 method get

Reads a single line from the input stream (usually the Standard Input or a file).

Read one line from the standard input:

    $*IN.get;

Read one line from a file:

    my $fh = open 'filename';
    my $line = $fh.get;


=head2 method getc

Read a single character from the input stream.

=head2 method eof

Returns L<Bool::True> if the read operations have exhausted the content of the file.

=head2 method lines

    method lines($limit = Inf)

Return a lazy list of the file's lines read via L<get>, limited to C<$limit> lines.

    =for code :allow<B>
    my @data;
    my $data-file = open 'readings.csv'
    for B<$data-file.lines> -> $line {
        @data.push($line.split(','))
    }

=head2 method words

    method words($count = Inf)

Return a lazy list of the file's words (separated on whitespace), limited
to C<$count> words.

    =for code :allow<B>
    my %dict;
    ++%dict{$_} for $*IN.words;
    say "Most common words: ", %dict.sort(*.value).reverse.[^5];

=head2 method split

    method split(splitter = "")

Returns a lazy list of strings found between the splitter, just like C<split>
on strings.

=head2 method comb

    method comb(comber = "")

Returns a lazy list of strings combed from the handle, just like C<comb>
on strings.

=head2 method print

    method print(*@text --> Bool)

Text writing; writes the given C<@text> to the filehandle.  See L<write>
to write bytes.

    my $fh = open 'path/to/file', :w;
    $fh.print("some text\n");
    $fh.close;

=head2 method read

    method read(IO::Handle:D: Int(Cool:D) $bytes --> Blob)

Binary reading; reads and returns up to C<$bytes> bytes from the filehandle.

=head2 method readchars

    method readchars(IO::Handle:D: Int(Cool:D) $chars --> Str)

Reading chars; reads and returns up to C<$chars> chars (graphemes) from the
filehandle.

=head2 method write

    method write(IO::Handle:D: Blob:D $buf)

Binary writing; writes C<$buf> to the filehandle.  See L<print> to write
characters.

=head2 method seek

     method seek(IO::Handle:D: Int:D $offset, SeekType:D $whence --> True)

Move the file pointer (that is the position at which any subsequent read
or write operations will begin,) to the byte position specified by
C<$offset> relative to the location specified by C<$whence> which may be
one of:

=item SeekFromBeginning

The beginning of the file.

=item SeekFromCurrent

The current position in the file.

=item SeekFromEnd

The end of the file.  Please note that you need to specify a negative
offset if you want to position before the end of the file.

=head2 method tell

    method tell(IO::Handle:D: --> Int)

Return the current position of the file pointer in bytes.

=head2 method ins

    method ins(IO::Handle:D: --> Int)

{'fraction_non_alphanumeric': 0.1050494350282486, 'fraction_numerical': 0.006179378531073447, 'mean_word_length': 3.532, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3356665', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1795, 'n_words': 761}