This is one of those moments where I wish I had one of those amnesia flash things from Men In Black. A quick survey via google has led me to believe that every example of code that uses the literal dienice subroutine out there is unadulterated crap, having been cut and pasted from some ancestral piece of mid 90's perl 4 code and hacked without any great understanding until it does what the person wanted. You probably do not want to be using this code as an example of good Perl programming. Of course I am probably being entirely unfair to some very good examples of code but there you go.

In addition to the comments of tachyon and davorg, you might also want to look at the facilities offered by the module CGI::Carp which, through its fatalsToBrowser mode and the set_message subroutine allows you to catch to catch a die and then present your own message to the users browser, of course it is unwise to be showing the real error message to the whole world but it often makes debugging easier, so you can for instance check if the request is coming from your IP and if so show the whole error otherwise showing a bland message:

#!/usr/bin/perl + use strict; + use CGI::Carp qw(fatalsToBrowser set_message); + + my $sub_message = sub { my ($message) = @_; if ($ENV{REMOTE_ADDR} eq '127.0.0.1') { print "Oops: $message"; } else { print "Unable to process, please try later" +; } }; + set_message($sub_message); + die "aiee!";

/J\


In reply to Re: What is dienice??? by gellyfish
in thread What is dienice??? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.