Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Fwiw, as pointed out elsewhere you can simplify the Perl 5 to:

    while (<>){ print };
Fwiw, in Perl 6, the canonical incantation is:

    .say for lines
where:

* thing.method calls method 'method' on thing (where thing is an object, or something that can behave as an object, which, in Perl 6, is any value). In the code above the 'say' method prints its arg, followed by a \n, to stdout.

* If thing isn't specified, the current topic (aka "it" aka $_) is assumed, so .say is being called on "it".

* 'for' sequentially sets the current topic ("it") to each of the items in the following list of things.

* 'lines' lazily reads lines (next chunk of text up to the next \n) from somewhere. The default somewhere is stdin.

A simpler incantation is:

    slurp.say
which slurps all of stdin as a list of lines and then says them all, but slurp isn't lazy, so it'll wait till it's read all of your stdin before writing any of it to stdout.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: