in reply to Peruse my code...
Two things stand out from a first pass look.
$message = $message . "somemore"; is better (read: shorter, clearer) written as $message .= 'somemore';. Also, note, you save a little in compile time (load time) if you use 'text', rather than "text" for string constants as the compiler knows it doesn't have to check for things to interpolate.
++ for reporting all errors in one pass, not each one individually as so many damn sites do.
I'm not quite sure why your sub PrintError has both exit 0; and return 1;. The latter will never be seen, and the former means that the script will abort after printing the error text, which maybe what you want, as otherwise the script would go on to say 'Blah Blah, All done'.$/;?
I don't find it aesthetically pleasing to exit a program from within a sub that way. I doesn't make too much difference in a script this short, but as the script grows in size, its likely to become confusing to those poor souls that come along after to maintain your work.
I think I would write that as
if ($found_err) { &PrintError; exit -1; # 0 often means ok, whereas this is an error exit. }
And remove the exit 0; from PrintError ... also the if your never going to check its value or if its always going to be the same, the return 1; serves little purpose.
Finally (yes, I know that's more than two things:), by putting the } on the end of the last line of the if block makes it harder to add in statements. Putting it on the next line by itself, it can replace one of your blank lines, retains the value of the white space, clearly indicates where the block ends, and makes it easier to add statements in there. That's all a matter of taste, and often raises near religious ferver, so I'll add, IM(NS)HO! :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Peruse my code...
by Anonymous Monk on Aug 31, 2002 at 13:07 UTC | |
by BrowserUk (Patriarch) on Aug 31, 2002 at 14:36 UTC | |
by Anonymous Monk on Aug 31, 2002 at 14:05 UTC | |
by jepri (Parson) on Aug 31, 2002 at 14:18 UTC | |
by jimbobn (Novice) on Aug 31, 2002 at 14:24 UTC | |
by jepri (Parson) on Aug 31, 2002 at 14:35 UTC |