Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Trouble with child processes

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


in reply to Trouble with child processes

Thats because you have to close RETHAND in the parent process. Also, I've always wanted to ask one of you guys... why do you indent your code so creatively???

Replies are listed 'Best First'.
Re^2: Trouble with child processes
by BrowserUk (Patriarch) on Nov 29, 2015 at 01:53 UTC
    why do you indent your code so creatively???

    Right back atchya!

    #!/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";

    Much nicer! :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Indeed, much better, I also prefer The One True Way (aka perltidy's default settings). BTW, that was a different anonymonk :)

        This is perl. there is no "One True Way"!

        TMTOWTDI forever!

        Thanks for all the help.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found