in reply to Croak or Die?

You use die when the error is something you or your code didn't do right. You use croak when it's something your caller isn't doing right. die "error: $!" indicates the error is on the line where the error occured. croak "error: $!" indicates the error is on the line where the caller called your code.

-Paul

Replies are listed 'Best First'.
Re^2: Croak or Die?
by bimleshsharma (Beadle) on Dec 24, 2012 at 10:02 UTC

    That's right, moreover it provides sub routine name from where croak called. This is better way to catch error.

Re^2: Croak or Die?
by Anonymous Monk on Jul 08, 2011 at 00:57 UTC
    Very well put. Thank you.