open(STDOUT, "> output")
|| die "can't open output: $!";
-And then these can be read directly or passed on to subprocesses.
+And then these can be accessed directly or passed on to subprocesses.
This makes it look as though the program were initially invoked
with those redirections from the command line.
sub head {
my $lines = shift || 20;
- return unless $pid = open(STDOUT, "|-");
+ return if $pid = open(STDOUT, "|-"); # return if parent
die "cannot fork: $!" unless defined $pid;
while (<STDIN>) {
- print;
last if --$lines < 0;
+ print;
}
exit;
}
=back
-For more detailed discussion about PerlIO see L<perlio>;
+For more detailed discussion about PerlIO see L<PerlIO>;
for more detailed discussion about Unicode and I/O see L<perluniintro>.
=head1 SEE ALSO