Perl Style: Break Programs into Separate Processes
Learn how to use the special forms of
open
. (See also tgent in TSA).# from PCB 16.5 head(100); sub head { my $lines = shift || 20; return if $pid = open(STDOUT, "|-"); die "cannot fork: $!" unless defined $pid; while (<STDIN>) { print; last if --$lines < 0; } exit; }
Forward to Data-Oriented Programming
Back to Break Complex Tasks Up
Up to index
Copyright © 1998, Tom Christiansen All rights reserved.
Tags
Feedback
Something wrong with this article? Help us out by opening an issue or pull request on GitHub