Auto die on failed sys calls?

Discussion in 'Perl Misc' started by J Krugman, Jul 6, 2004.

  1. J Krugman

    J Krugman Guest

    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.
    J Krugman, Jul 6, 2004
    #1
    1. Advertising

  2. J Krugman

    Anno Siegel Guest

    J Krugman <> 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
    Anno Siegel, Jul 6, 2004
    #2
    1. Advertising

  3. 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
    John W. Krahn, Jul 7, 2004
    #3
  4. J Krugman

    Anno Siegel Guest

    John W. Krahn <> 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
    Anno Siegel, Jul 7, 2004
    #4
  5. Anno Siegel wrote:
    >
    > John W. Krahn <> 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
    John W. Krahn, Jul 7, 2004
    #5
  6. J Krugman

    J Krugman Guest

    In <> "John W. Krahn" <> 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.
    J Krugman, Jul 8, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Sheen

    Die IDE Die

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    415
    Natty Gur
    Jan 26, 2004
  2. Lloyd Sheen

    More Die IDE Die

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    433
    Alvin Bruney
    Jan 25, 2004
  3. linkswanted
    Replies:
    1
    Views:
    883
  4. Brian Wakem
    Replies:
    0
    Views:
    101
    Brian Wakem
    Apr 23, 2007
  5. Jai
    Replies:
    1
    Views:
    149
    Neil Cerutti
    Nov 19, 2013
Loading...

Share This Page