in reply to Testing Return Values
I assume that by saying "any function, returns 1 upon success", you're referring to functions documented in File::Copy, for they're documented to do just that. In general functions that make system calls return Boolean true upon success, and false upon failure. But check the documentation for specific functions if you want to count on "true" being "1".
Anyway, on to your question. You didn't really explain what it is that you want to do. Your sample code snippet is actually fine, if applied correctly. Here's an example:
if( copy $source, $dest ) { print "Success!"; } else { warn $!; }
The logical short circuit operators, "and", "&&", "or", "||", can be used as a shorthand for more formal or explicit control flow syntax. In the example I provided, I used "if(){}". Here's another:
barf "Green pigs: $!" unless copy $source, $dest;
I'll leave it to you to implement the barf() function. ;)
Dave
|
|---|