in reply to die properly

eval { &feed; }; if ( $@ ) { &email_error; }

  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

Replies are listed 'Best First'.
Re^2: die properly
by Anonymous Monk on May 12, 2005 at 18:28 UTC
    I could use your code right after the sub &feed or inside the subroutine?
      &feed; is the call to the subroutine. You wrap the call in an eval-block and check $@ to see if the subroutine died or not.

      • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
      • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
        Ok, that's how I did
        eval { &feed; }; unless ( $@ ) { &error; } sub feed { ...code... while($l < $2) { ...code... } die "Could not retreive data"; }

        And it seems to be working.