Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gnat (29)

  (email not shown publicly)

Journal of gnat (29)

Thursday April 24, 2003
07:40 AM

Alarm bells

[ #11825 ]
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.


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • this [] will make thing that code was written by larry himself. yay for cpan :)
  • 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.



    • 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!

      • 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?
      • 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! :-)


        • 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").
        • 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).
  • 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 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 that wasn't really being used as should be, and n
    • ...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.