Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Rigorous File operation error checking

Reply
Thread Tools

Rigorous File operation error checking

 
 
Marc S. Gibian
Guest
Posts: n/a
 
      07-15-2003
I am putting together a Perl tool to manage a large set of tasks
related to building a rather complex set of software. One of the goals
for moving to Perl is to provide very rigorous error checking and
handling. One area that has me puzzled is error checking some of the
file system operations. Just simple things such as open, rename,
unlink, print and some others ... all the sample code I've seen uses
them in a form of:

open(...) || die "message $!"

Given this is part of a large tool, I'd far prefer to capture the
error code/message, report it via my messaging & tracing mechanism so
it gets recorded in the log file as well as getting displayed to the
user, and then decide if its a fatal error or if I'm going to attempt
to forge ahead in spite of it.

I've tried capturing a status return:

$status = open(...);

but this does not seem to return a useful return value.

Can someone please help me understand how I might provide the level of
error checking and control that I am looking for?

Thanks in advance for your assistance.

-Marc
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      07-17-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://www.velocityreviews.com/forums/(E-Mail Removed) (Marc S. Gibian) wrote in
news:(E-Mail Removed) :

> The simplest solution is:
>
> open(...) or function("something", "$!");
>
> There are lots of other techniques in common usage, including
> exceptions with try {
> open(...);
> }
> catch { }
>
> blocks.


Perl has try/catch?

- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxZz2GPeouIeTNHoEQKGCwCgoIrobbYX7ZYS8y0XUyzPA8 hngscAoM3I
eIPV5XvYzpDayjWdvq+n8U5f
=ltjM
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
 
Andrew Savige
Guest
Posts: n/a
 
      07-22-2003
"Eric J. Roode" <(E-Mail Removed)> wrote in message news:<Xns93BB3D33E89A5sdn.comcast@206.127.4.25>...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> (E-Mail Removed) (Marc S. Gibian) wrote in
> news:(E-Mail Removed) :
>
> > The simplest solution is:
> >
> > open(...) or function("something", "$!");
> >
> > There are lots of other techniques in common usage, including
> > exceptions with try {
> > open(...);
> > }
> > catch { }
> >
> > blocks.

>
> Perl has try/catch?


In Perl 5, I suppose a rough translation is:
try -> eval block
throw -> die
catch -> test $@
though some CPAN modules allow you to use the words try and catch.
Some links on Perl exception handling:
http://www.perl.com/pub/a/2002/11/14/exception.html
http://search.cpan.org/dist/Exception-Class/
http://search.cpan.org/author/GBARR/Error-0.13/Error.pm
http://www.perlmonks.com/index.pl?node=230799
http://www.perl.com/pub/a/2002/01/15/apo4.html
http://www.perl.com/pub/a/2002/04/01/exegesis4.html

/-\
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boolean operation and arithmetic operation Buzz Lightyear C++ 10 08-12-2009 01:27 PM
I/O operation, file operation behaviou raan C++ 2 08-16-2007 07:13 PM
Executing a static non-main operation in a jar file contained withina war file O.B. Java 0 06-24-2006 05:47 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
The file 'bin\WebProj.dll' cannot be copied to the run directory. The requested operation cannot be performed on a file with a user-mapped section open. J Gao ASP .Net 0 07-28-2003 04:18 PM



Advertisments