Closed Thread Icon

Preserved Topic: Catching an Uncaught Exception (in perl) (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Preserved Topic: Catching an Uncaught Exception (in perl) (Page 1 of 1)" rel="nofollow" >Preserved Topic: Catching an Uncaught Exception (in perl) <span class="small">(Page 1 of 1)</span>\

Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-17-2001 23:16

Hey all,

Short story, I'm writing a script that creates a directory on the server. I'm trying to use the mkpath function (part of the File::Path module) and I'm having a problem. When it can not create directory (the parent is unwriteable). The module causes an Uncaught Exception and kills the script. This doesn't work for me since I want to be able to go to a second option if it can't create the directory.

Before I write a looping script using mkdir, does anyone know how to catch this exception before it kills the script?

:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-18-2001 00:26

Exception hanlding in PERL is done by using eval { } statement and then checking for error(s) in $@, like this:

eval {
&nbsp;&nbsp;&nbsp;&nbsp;# your code here
if ($@) {
&nbsp;&nbsp;&nbsp;&nbsp;# handle exception

Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 10-22-2001 19:21

I think Perl also has file test operators. There's probably something for writeable.

« BackwardsOnwards »

Show Forum Drop Down Menu