Copy stdin to stdout: Difference between revisions
→{{header|Perl 6}}: Add a Perl 6 example
(→{{Header|Perl}}: this is a shell invocation of perl) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example) |
||
Line 7:
perl -pe ''
</lang>
=={{header|Perl 6}}==
When invoked at a command line: Slightly less magical than Perl / Sed. The p flag means automatically print each line of output to STDOUT. The e flag means execute what follows inside quotes. ".lines" reads lines from the assigned pipe (file handle), STDIN by default.
<lang perl6>perl6 -pe'.lines'</lang>
When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print)
<lang perl6>.say for lines</lang>
=={{Header|sed}}==
|