Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

(Knob)Re: Forking Multiple Children

by knobunc (Pilgrim)
on Jun 19, 2001 at 16:36 UTC ( #89617=note: print w/ replies, xml ) Need Help??


in reply to Forking Multiple Children

You appear to be passing the commands in to the standard input of the program. If there isn't a good reason for that then you can pass them on the command line:

my ($command1, $command2, $command3) = @ARGV; $command2 = 'default' unless defined $command2; $command3 = 'hoo hah' unless defined $command3; # OR my $command1 = shift or die; # Ideally call a subroutine to print usag +e and die my $command2 = shift || 'default'; my $command3 = shift || 'hoo hah';

If you have to read from STDIN then you can check to see if it still has stuff available using the eof function:

my $command1 = <STDIN>; chomp($command1); my ($command2, $command3) = ('default', 'hoo hah'); unless (eof(STDIN)) { $command2 = <STDIN>; chomp $command2; unless (eof(STDIN)) { $command3 = <STDIN>; chomp $command3; } }

-ben


Comment on (Knob)Re: Forking Multiple Children
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-29 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls