http://qs321.pair.com?node_id=310408


in reply to open failure code

Precedence and operator binding is the issue. But...why not just.....

if (open FH, $log) { ....send tail of log file... } else { ....send "server is down. Perl say $!" }

Note the error code (string reason) is set in $! if open, print, close, mkdir, unlink.....fail. Internal Perl functions return 1 if they succeed, 0 or undef if they fail. If you want to do the  || $scalar = 'blah' you can do this:

blah() || do{ $scalar = 'blah'; more_stuff() }

cheers

tachyon