Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Trouble with child processes

by Anonymous Monk
on Nov 29, 2015 at 01:00 UTC ( [id://1148788]=note: print w/replies, xml ) Need Help??


in reply to Trouble with child processes

Much easier as "forked open"

#!/usr/bin/perl # http://perlmonks.org/?node_id=1148787 use strict; use warnings; my $total = 0.0; my @waitlist = qw(0 200 400 800 1000); my @fhs; foreach my $item (@waitlist) { if( open my $fh, '-|' ) { push @fhs, $fh; } else { my $h = 1.0 / 1200.0; my $sum = 0.0; for my $i ($item .. $item + 200 ) { my $x = $h * ($i - 0.5); $sum += 4.0 / (1.0 + $x*$x); } my $ret=$sum * $h; print $ret; #warn "$item exiting\n"; exit; } } for my $fh ( @fhs ) { $total += (<$fh> + 0.0); print "$total\n"; close $fh; } print " $total\n"; print "All done!\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1148788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-19 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found