Test, test, test. Yes the second snippet is straight forward, but im sure there would be all sorts of ways to mess with it. How about something like the following..
# # I split the code, but I dont think it would need to be on # a new line in an 80 char window # my $main_menu = new Menu("main") || &some_error_routine("Failed to create menu obj! $main_menu->err\ +n"); my $menu_item = param('menu_item') || &some_error_routine("No menu_item passed to cgi!"); my $active_menu_id = get_active_menu($menu_item) || &some_error_routine("Cant collect menu_id!!\n"); # # There should probably be a test here as well # $main_menu->active_menu_id($active_menu_id); $main_menu->output;
If the sub routines return 0, nothing, or undef the second half of a line will be executed. Also when attempting to debug later, you can do a couple of things. Within the some_error_routine, you can watch for say a global $DEBUG, and depending on what the value of it is, you can determine what types of messages to send out to the log file, if debug isnt defined and you receive messages to be logged, you can still trim down your output, but you dont need to spend X amount of time adding debug statements to the rest of your code. You simply go to main, define 1 scalar, and then run the code again. Once your done with testing, you whack the scalar and everything goes back to normal.

I find it best for myself, that once a app reaches a certain point in either complexity or frequence of run time, I add a simple error logging sub. But hey its just works for me :)

Edit: Post morning coffee, I realize I didn't really stress what I wanted to. Basically you can control the behaviour of your code in terms of logging and dieing from a single sub. Also with logging this way, and parsing the error log, you should be able to quickly figure out where in the code you failed and for what reason. You could get this done via croak/warn/die, but if the app is getting as big as you say, its easier for me to control it all from a single point, as opposed to multiple source files and libs.

/* And the Creator, against his better judgement, wrote man.c */

In reply to Re: Re: The -w switch on a web application by l2kashe
in thread The -w switch on a web application by Heidegger

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.