Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Auto die on failed sys calls?

Reply
Thread Tools

Auto die on failed sys calls?

 
 
J Krugman
Guest
Posts: n/a
 
      07-06-2004



Is there any way to instruct perl to die whenever a system call
(e.g. through open, opendir, backticks, system, etc.) fails?

The aim is to be able to enclose a series of such calls in a single
eval block, and catch any failures at the end, instead of checking
for them after each system call.

Thanks!

jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.

 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      07-06-2004
J Krugman <(E-Mail Removed)> wrote in comp.lang.perl.misc:
>
>
>
> Is there any way to instruct perl to die whenever a system call
> (e.g. through open, opendir, backticks, system, etc.) fails?


No, there isn't.

Note also that open and opendir belong in a different category than
backticks and system. The first ones call kernel- or library routines,
the second ones call external programs.


> The aim is to be able to enclose a series of such calls in a single
> eval block, and catch any failures at the end, instead of checking
> for them after each system call.


One could think of tie-ing $! so that it dies when something non-zero
is stored there, but that doesn't work either. The values in $! get
there via magic, not the standard SV procedure, so the tie is ignored.

Anno
 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      07-07-2004
J Krugman wrote:
>
> Is there any way to instruct perl to die whenever a system call
> (e.g. through open, opendir, backticks, system, etc.) fails?
>
> The aim is to be able to enclose a series of such calls in a single
> eval block, and catch any failures at the end, instead of checking
> for them after each system call.


perldoc Fatal


John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      07-07-2004
John W. Krahn <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> J Krugman wrote:
> >
> > Is there any way to instruct perl to die whenever a system call
> > (e.g. through open, opendir, backticks, system, etc.) fails?
> >
> > The aim is to be able to enclose a series of such calls in a single
> > eval block, and catch any failures at the end, instead of checking
> > for them after each system call.

>
> perldoc Fatal


Ah... interesting. Thanks for mentioning it, I never noticed that
module.

Anno
 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      07-07-2004
Anno Siegel wrote:
>
> John W. Krahn <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> > J Krugman wrote:
> > >
> > > Is there any way to instruct perl to die whenever a system call
> > > (e.g. through open, opendir, backticks, system, etc.) fails?
> > >
> > > The aim is to be able to enclose a series of such calls in a single
> > > eval block, and catch any failures at the end, instead of checking
> > > for them after each system call.

> >
> > perldoc Fatal

>
> Ah... interesting. Thanks for mentioning it, I never noticed that
> module.


You learn something new every day. At least I know I do.


John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
J Krugman
Guest
Posts: n/a
 
      07-08-2004
In <(E-Mail Removed)> "John W. Krahn" <(E-Mail Removed)> writes:

>J Krugman wrote:
>>
>> Is there any way to instruct perl to die whenever a system call
>> (e.g. through open, opendir, backticks, system, etc.) fails?
>>
>> The aim is to be able to enclose a series of such calls in a single
>> eval block, and catch any failures at the end, instead of checking
>> for them after each system call.


>perldoc Fatal


Great!

Thanks!

jill

--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.

 
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
re: @Don postet euch den Film des Jahres " Die rache der Sith " in MVCD (028/110] - "Star Wars Episode 3 - Die Rache der Sith ( 1_2 MVCD ) ein @Don post.part28.rar" Marco Computer Support 0 05-22-2005 01:25 PM
comp.sys.mac.games.misc,comp.sys.ibm.pc.hardware.misc,comp.mail.pegasus-mail.ms-windows,comp.databases.paradox,comp.dcom.sys.cisco . Cisco 0 06-19-2004 07:48 AM
Die IDE Die Lloyd Sheen ASP .Net 2 01-26-2004 04:59 AM
More Die IDE Die Lloyd Sheen ASP .Net 5 01-25-2004 02:34 PM
I want to be a hacker/nerd b4 I die. Ghost issues (now and after I die) O.Phooey Computer Support 4 07-05-2003 08:35 PM



Advertisments