use Perl Log In
Warnings and Stricture
Ask any perl expert what's one of the first things they tell newbie perlers and invariably ``always put a "use strict;" at the top of your program and turn warning on'' is in the top 3. So why not make that the default and provide a simple command line option to turn them off?
In perl's early days only "experts" used perl, so the "don't warn" policy was correct as perlers either knew what they were doing or they knew enough to figure it out when things went wrong. But today, perl's user base is many orders of magnitude larger and the expertise of its users more varied. It seems to me that perl should adapt to these new conditions by helping the newbies while still apeasing the experts. I, for one, wouldn't mind warnings and stricture on by default as long as there was a simple method to turn them off.
What does the rest of the use Perl; community think?
I think no way until we get lexical warnings! Oh, wait

Maybe... Build-time decision, perhaps? (Score:1, Interesting)
Wonder how many of my old scripts would croak as a result... Hm.
Inane warning used only once: possible typo (Score:1, Interesting)
I've barely dipped my toes into perl 5.6 so I'm not sure how much better things have gotten, but the "used only once" test is a good indicator as far as I'm concerned. I
Re:Inane warning used only once: possible typo (Score:1, Interesting)
BEGIN {
# this is the worst damned warning ever, so SHUT UP ALREADY!
$SIG{__WARN__} = sub { warn @_ unless $_[0] =~
I dont agree (Score:1, Interesting)
"Love, work and knowledge are the well-springs of our life. They should also govern it." - W. Reich
Support scripts? (Score:1, Interesting)
Not a good idea.... (Score:1, Interesting)
As for the ``possible typo'' warning, the new our $var construct should finally make it convenient to avoid.
Re:our() and "possible typo" (Score:1, Interesting)
Re:I dont agree (Score:1, Interesting)
Re:Inane warning used only once: possible typo (Score:1, Interesting)
BTW, is there really ever a need to use a variable only once?
glauber
Re:Inane warning used only once: possible typo (Score:1, Interesting)
Consider:
# foo.pl
$foo = 'bar';
-----------
#!/usr/bin/perl -w
# myscript.plx
require 'foo.pl';
print $foo;
__END__
Yields:
# Name "main::foo" used only once: possible typo.
File 'Bourque:Desktop Folder:Untitled #2'; Line 3
bar
Huh? Oh yeah, I use it only once _at compile time_. Oopsie. Wrapping the require statement in BEGIN { }
Re:Inane warning used only once: possible typo (Score:1)
use warnings;
{
no warnings 'once';
print *Another::Package::used_once = sub { 1 };
}
Re:I dont agree (Score:1, Interesting)
This is bogus. We already have the situation where an upgrade of perl may break old programs. Anyone who upgrades perl blindly is a fool.
Warnings and stricture don't force you to do things in a unique way. Perl has no ego, it doesn't care how you do things. If 80% (
Re:Support scripts? (Score:1, Interesting)
Re:I dont agree (Score:1, Interesting)
I don't think such numbers matter much. I think right and wrong, when applicable, matter. And I think they are applicable here. I think it is wrong to force me to have to type an extra flag or something to get my hundreds of one-liners and short scripts to compile.
So let's talk about numbers in this manner: you think it is bogus to say old programs would break, that old programs are broken by many
perl -w (Score:1, Interesting)
As with the 'use strict' pragma as well, it slows your program down a bit, so I usually keep the warnings while developing, but then take them out on production code.
Speaking of warnings... from Slash.pm (Score:1, Interesting)
This is from Slash.pm, the main module that powers slashdot and use.perl.org. I always thought this was some of the silliest hackery I'd every seen:
BEGIN { /Use of uninitialized value/ };
# this is the worst damned warning ever, so SHUT UP ALREADY!
$SIG{__WARN__} = sub { warn @_ unless $_[0] =~
}
darren
(darren)
Re:I dont agree (Score:1, Interesting)
perl and newbie-perl.
I hope I don't have to put the smiley for you to tell that I'm joking here.
stricture and warnings compiled in (Score:1, Interesting)
I think it could be useful, and here is why. As duff said, there are many new programmers which we always tell the