P
pgodfrin
Greetings,
I'd like to die() with a return code (no pun intended) - I'm not sure
how to do it without wrapping some extra code around die. Any
thoughts?
Here's a snippet:
if($?) { $return_code=$?; die "Error generating temp file names\n" ;}
....
END
{
if (defined WL) { close WL; }
print "Script ended. RC=$return_code \n";
$?=$return_code;
}
This works fine if I explicitly code both steps - first setting the
$return_code and then executing die. But, this kind of statement won't
permit that 'cause of the nature of the or operator:
mkdir($tgt_dir) or die "Mkdir ($tgt_dir) command failed.\n";
Is there an elegant way to this or will I need to use if statements
for anything I want to test for errors?
pg
I'd like to die() with a return code (no pun intended) - I'm not sure
how to do it without wrapping some extra code around die. Any
thoughts?
Here's a snippet:
if($?) { $return_code=$?; die "Error generating temp file names\n" ;}
....
END
{
if (defined WL) { close WL; }
print "Script ended. RC=$return_code \n";
$?=$return_code;
}
This works fine if I explicitly code both steps - first setting the
$return_code and then executing die. But, this kind of statement won't
permit that 'cause of the nature of the or operator:
mkdir($tgt_dir) or die "Mkdir ($tgt_dir) command failed.\n";
Is there an elegant way to this or will I need to use if statements
for anything I want to test for errors?
pg