From: | Bob McConnell <rmcconne(at)lightlink(dot)com> |
---|---|
To: | felix(at)crowfix(dot)com |
Cc: | PGSQL-Novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: DBI, savepoints, transactions, and AutoCommit -- NOT A BUG |
Date: | 2011-11-03 22:05:51 |
Message-ID: | 4EB3103F.2010303@lightlink.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
felix(at)crowfix(dot)com wrote:
> On Wed, Nov 02, 2011 at 08:23:09PM -0400, Daniel Staal wrote:
>> --As of November 2, 2011 4:53:18 PM -0700, felix(at)crowfix(dot)com is alleged to
>
>>> # !/usr/bin/perl -w
>> As the Perl guy at my office: You *do* know the difference between this and
>> 'use warnings;', right? And why the latter is almost always what you want?
>> (Sorry, it's one of those things I've learned to jump on, as it's often
>> just Cargo Cult Programming...)
>
> It's been ages since I settled on -w instead of use warnings. I know
> there's a difference, I have some vague recollection of -w being
> "better", whatever that means, but it's one of those things that I
> have "known" for so long that I no longer know what I once knew :-)
> All my perl books -- scratch that, I just googled for it. -w is all
> or nothing, and especially it enables warnings for modules which might
> be better off without warnings. So it says.
>
> But that advice seems a mite stale nowadays. It says use warnings was
> introduced in 5.6, so any older modules will possibly barf, or any
> newer modules which turn warnings off for their own reasons. So why
> would I care about this now? I don't recollect any untoward warnings
> in years of programming Perl.
There are numerous reasons why "use warnings;" is far better than "-w".
First of all, the former is localized. Well known modules turn warnings
off for the duration so they won't confuse you. You can do the same with
code that you are certain is bug free. Second, it is more granular. You
can turn specific classes of warnings off or on (see 'perldoc
warnings'). Third, when combined with "use strict;" it can lead you to
those simple, but difficult to uncover, typographic errors we all make.
You know, the misspelled variable, the variable where you capitalized
the wrong letter, or left off the dollar sign.
You should probably get to know both of these a bit better. Current best
practices is to start every script with these two lines:
use warnings;
use strict;
That simple change will identify a lot of problems that you might not
even know you are tripping over.
Bob McConnell
N2SPP
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Landscheidt | 2011-11-04 01:45:51 | Re: Foreign key constraint violation when using table inheritance |
Previous Message | felix | 2011-11-03 17:47:57 | Re: DBI, savepoints, transactions, and AutoCommit -- NOT A BUG |