yangy has asked for the wisdom of the Perl Monks concerning the following question:
# page 535 in book Programming Perl#!/usr/bin/env perl use v5.14; tee("/tmp/foo", "/tmp/bar", "/tmp/glarch"); while (<>) { print "$ARGV at line $. => $_"; } close(STDOUT) || die "can't close STDOUT: $!"; sub tee { my @output = @_; my @handles = (); for my $path (@output) { my $fh; # open will fill this in unless (open ($fh, ">", $path)) { warn "cannot write to $path: $!"; next; } push @handles, $fh; } # reopen STDOUT in parent and return return if my $pid = open(STDOUT, "|–"); print "\$pid is : $pid"; die "cannot fork: $!" unless defined $pid; # process STDIN in child while (<STDIN>) { for my $fh (@handles) { print $fh $_ || die "tee output failed: $!"; } } for my $fh (@handles) { close($fh) || die "tee closing failed: $!"; } exit; # don't let the child return to main! }
when I run this in ubuntu shell but there is an error:
cannot fork: no such file or directory at ./tf6.pl line 27.
why? somebody give some advice.thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: example in book of Programming Perl does not work.
by aitap (Curate) on May 30, 2013 at 06:07 UTC | |
by yangy (Novice) on May 30, 2013 at 08:51 UTC | |
by MidLifeXis (Monsignor) on May 30, 2013 at 12:37 UTC | |
by yangy (Novice) on May 30, 2013 at 15:27 UTC | |
by derby (Abbot) on May 30, 2013 at 12:43 UTC | |
|
Re: example in book of Programming Perl does not work.
by farang (Chaplain) on May 30, 2013 at 06:09 UTC | |
by yangy (Novice) on May 30, 2013 at 08:53 UTC | |
|
Re: example in book of Programming Perl does not work.
by vinoth.ree (Monsignor) on May 30, 2013 at 05:30 UTC |