Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: How to skip to next Command line

by Perl Mouse (Chaplain)
on Jan 25, 2006 at 09:35 UTC ( [id://525390]=note: print w/replies, xml ) Need Help??


in reply to Re: How to skip to next Command line
in thread How to skip to next Command line

The problem with that solution is that if the fork fails, block.exe will be executed, but the rest of the program won't. Also, system returns false if the command was succesful, and any error status is in $?, not $!.

A better way would be:

my $pid = fork; die "Fork failed: $!" unless defined $pid; unless ($pid) { system "C:\\block.exe"; die "Command failed with exit code ", $? >> 8 if $?; exit; } print "processing second line...\n";
Or, if you don't want to handle failures of block.exe in your program:
my $pid = fork; die "Fork failed: $!" unless defined $pid; unless ($pid) { exec "C:\\block.exe"; die "exec failed: $!"; } print "processing second line...\n";
Perl --((8:>*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found