develooper Front page | perl.perl5.porters | Postings from February 2011

[perl #84942] perltie.pod READLINE list context

Thread Previous
From:
Father Chrysostomos via RT
Date:
February 25, 2011 22:01
Subject:
[perl #84942] perltie.pod READLINE list context
Message ID:
rt-3.6.HEAD-28241-1298700110-1565.84942-15-0@perl.org
On Fri Feb 25 14:15:17 2011, kryde wrote:
> In perltie.pod the handle READLINE says
> 
>     The method should return undef when there is no more data.
> 
> which made me think that's what it should always do, and didn't need
>    to
> pay attention to wantarray().
> 
> If I'm not mistaken in list context READLINE should return empty list
> for no more data.  It'd be good if the docs noted that, and perhaps
> cross referenced to perlfunc for the gory details of what readline
> should do.
> 
> Maybe something like the following, unless someone can think of a
>    better
> contrivance for the sample.
> 
> 
> =item READLINE this
> X<READLINE>
> 
> This method is called when the handle is read via C<E<lt>HANDLEE<gt>>
> or C<readline HANDLE>.
> 
> As per L<perlfunc/readline>, in scalar context it should return the
> next line, or C<undef> if no more data.  In list context it should
> return all remaining lines or an empty list if no more data.  The
> input record separator C<$/> (see L<perlvar>) is included in the
> strings, or C<$/> C<undef> means "slurp" mode.
> 
>     sub READLINE {
>       my $r = shift;
>       if (wantarray) {
>         return ("all remaining\n",
>                 "lines up\n",
>                 "to eof\n");
>       } else {
>         return "READLINE called $$r times\n";
>       }
>     }

Thank you. I applied your text as commit 2207fa4, but then reworded it a
bit with commit 26f1b91.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About