" ...
>     open(FILE,">somefile") or die "Cannot open 'somefile' $!";

Not being argumentative here but I've seen this said before.  Not
really sure why it is important.  I mean why is the open action
singled out for this protection.  It seems other actions could also
cause a misfired script?
..."   --Harry

Hi Harry,

Your scepticism is appropriate here, although possibly for the wrong reason.  The die 
function can be very useful working in console mode, but it is hell for CGI debugging. 
 Since errors go into the server error log, which tends to be accessible only to the 
system admin, it can be damn near useless to have die statements in a CGI script.

File opening is particularly vulnerable to forces external to your program compared 
with other operations.  The basic concept is that if you don't have a source for your 
information, you have nothing to go on.  Still, unless further activity in your 
scri8pt can be destructive of data, it may not be necessary to die.  For cont3exts 
where die leaves me without sufficient information for debugging, I prefer print:

open (NEWMEMBERS, "< newmember.txt" or print "<h3> Sorry, file newmembers.txt did not 
open because $!</h3>\n";

Of course, I am now in debugging mode.  Before I release my CGI for public use, I will 
probably substitue a cleanup function:
$FileName = "newmember.txt"
open (NEWMEMBERS, "< $FileName" or SignalOpenFailureAndDie($FileName, $!);
where SignalOpenFailureAndDie() prints a page briefly explaining to the user why they 
are not getting expected results.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to