Alarm bells

gnat on 2003-04-24T12:40:22

Going over someone's code and within five lines I'd seen no -w, no check of the return value of open, and a halfassed homebrew reimplementation of the standard FileCache module. The alarm bells were ringing so loud in my head that they temporarily drowned out the voices telling me to kill.

--Nat


try this one...

sungo on 2003-04-24T14:41:23

this will make thing that code was written by larry himself. yay for cpan :)

I, Heretic

rjray on 2003-04-24T19:55:57

I don't generally put -w in start-up line. I figure that the average runner of the tool isn't going to care enough to look up the warnings they get, and when I'm testing/debugging I run the script using "perl -w" anyway. It makes it easier with shell-history-substitution to add/subtract other flags like -d.

On the other hand, anything that is important enough to go from one-liner to actual script runs under strict, even if it's only 10-15 lines long.

Re:I, Heretic

jjohn on 2003-04-25T12:42:00

I don't generally put -w in start-up line.

Me too. I include 'use strict' in the smallest of scripts, but -w is bloody useless. 'perl -wc ' is great though. Screw runtime warnings.

OH PLEASE WARN ME ABOUT 'use of uninitialized value in concatentation (.)' AGAIN!

Re:I, Heretic

vsergu on 2003-04-25T14:33:15

I've found that 'use of uninitialized value in concatenation (.)' usually indicates something wrong. Remember that it doesn't warn if you're just using .= on an uninitialized variable. It happens, for example, when I interpolate an uninitialized variable into a string. Do you normally want to do that?

Re:I, Heretic

jjohn on 2003-04-25T19:58:43

yup. Most of the time, I don't care.

Re:I, Heretic

gnat on 2003-04-26T01:24:10

Interesting difference in coding style. I like to make my programs -w clean by initializing variables and generally being a tidy Kiwi. That way if I get an "uninitialized value in concatenation", I know something's happened that I didn't expect. I use Perl's warnings to help me find bugs, rather than treating them as an irritation to be muzzled. I don't have a high opinion of my programming skills and will take help whereever I can get it! :-)

--Nat

Re:I, Heretic

vsergu on 2003-04-27T01:05:35

Same here, but in fact I've internalized the rules for when warnings occur enough that I don't initialize things that Perl doesn't warn about, like strings that I'm going to use .= on, or arrays that I'm going to push() things onto, or sometimes booleans that I may later set to true. And now when I use PHP I get irritated because PHP's warnings are different and I have to do more initialization -- also it isn't as good as Perl at warning about possible typos in variable names ("name only used once").

Re:I, Heretic

pudge on 2003-04-30T14:27:19

I use -w, and this:
# this is the worst damned warning ever, so SHUT UP ALREADY!
$SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /Use of uninitialized value/ };
I like -w. In Slash we just have so many lines of code that variables are not always initialized (and frankly, I find that initializing every variable causes a lot of clutter when you already have a ton of lines of code).

mMmM yes, Help you to read, it can.

WebDragon on 2003-04-24T20:06:57

Having just downloaded WebMin to have a look-see at how it did what it did, when I was informed that it was made of Perl, I was quite astounded to see that it used the old cgi-lib.pl constructs and stuff that looks more like perl 4 than perl 5 (at least from what little I remember.. I wasn't really around then much but I do recall Perl looking a LOT more confusing back then than it does now)

A quick grep through the source found one instance of CGI.pm that wasn't really being used as CGI.pm should be, and nowhere near to the extent of its capabilities.

I swear to god, if I had more time on my hands I'd shred webmin and rewrite the entire thing.

As the Debian webmin maintainer

jaldhar on 2003-04-25T04:25:08

...I've had to dig into the code a lot and I've found it's not so bad. The thing I really wish jcameron had done was to use some kind of template scheme. Currently html is hard coded in all over the place.