Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Check if "System" was succesful

by vaevictus (Pilgrim)
on Apr 09, 2004 at 13:42 UTC ( #343903=note: print w/ replies, xml ) Need Help??

in reply to Check if "System" was succesful

but for a system related WTDI,

my $result = system("copy bleh blah"); #system returns opposite ... IIRC if(! $result) { print "success\n"; } else { print "oh no!\n"; }

Comment on Re: Check if "System" was succesful
Download Code
Replies are listed 'Best First'.
Re: Re: Check if "System" was succesful
by BazB (Priest) on Apr 09, 2004 at 16:20 UTC

    The usual (and slightly more compact) way to check a system call is:

    system( $cmd ) == 0 or die "System call failed: $!";

    The " == 0" deals with the fact that system returns 0/false on success, not true like most perl functions.

    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2016-02-12 15:35 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (407 votes), past polls