Copy stdin to stdout: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: typo) |
||
Line 9: | Line 9: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
When invoked at a command line: Slightly less magical than Perl / |
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> |
<lang perl6>perl6 -pe'.lines'</lang> |
Revision as of 14:04, 11 November 2018
Copy stdin to stdout is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
Perl
<lang sh> perl -pe </lang>
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>
sed
<lang sh> sed -e </lang>