Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^4: unless/if

by sgifford (Prior)
on Oct 12, 2005 at 15:49 UTC ( #499548=note: print w/ replies, xml ) Need Help??

in reply to Re^3: unless/if
in thread unless/if

If you stick a "\n" on the end of the string you pass to die, you won't get a line number.

Apart from better readability and being a standard idiom, the nice thing about using die is you can catch it in a eval, making it possible to deal with exceptional conditions at a higher level.

Comment on Re^4: unless/if
Select or Download Code
Replies are listed 'Best First'.
Re^5: unless/if
by Moron (Curate) on Oct 18, 2005 at 12:07 UTC
    Adding the "\n" to get rid of traceback info is the least part of the problem and does not address the real situation that professional programmers will frequently encounter, requiring more to be done on encountering a fatal error that needs to be brought to user's rather than just an IT person's attention and which may need support some time after the fact.
    <condition> or ProjectName::Die( $gddref, "message content" ); # in package ProjectName sub Die my $gddref = shift; # ref. to global data dictionary my $content = shift; my $UICB = $gddref -> { CB }{ UIOUT }; my $logref = $gddref -> { FH }{ LOGOUT }; &$UICB( "FATAL ERROR: $content" ); # which may or may not end up # using die depending # on the user interface print $logref ( ProjFormatTime( localtime() ) . ": $content\n"; exit 1; # having met such particular messaging requirements # die with or without "\n" is no longer an obvious idea. }
    which is more to type than:<code> Die( "


    Free your mind

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://499548]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2015-10-10 16:58 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (257 votes), past polls