From: Robin on
I know this is a pretty stupid question, maybe, but is it better to
use strict? I have never gotten a concise answer to this question
because there reallty isn't any docs on it.
thanks,
-ro9bin
From: Randal L. Schwartz on
>>>>> "Robin" == Robin <robin1(a)cnsp.com> writes:

Robin> I know this is a pretty stupid question, maybe, but is it better to
Robin> use strict? I have never gotten a concise answer to this question
Robin> because there reallty isn't any docs on it.

% perldoc strict

NAME
strict - Perl pragma to restrict unsafe constructs

SYNOPSIS
use strict;

use strict "vars";
use strict "refs";
use strict "subs";

use strict;
no strict "vars";

DESCRIPTION

[...]

You have a strange meaning of "isn't any". Care to elaborate?

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn(a)stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
From: Owen on
On Feb 16, 2:06 pm, Robin <rob...(a)cnsp.com> wrote:
> I know this is a pretty stupid question, maybe, but is it better to
> use strict? I have never gotten a concise answer to this question
> because there reallty isn't any docs on it.
> thanks,
> -ro9bin

There are a number of good reasons to use strict, however, in my case
I use it to help in de-bugging and all other side benefits are a
bonus.

90% of my errors are misspelt variables, IE, somwhere you have

# my $blah;

and later you use $blaj by mistake, it will tell you in its own
fashion that $blaj is perhaps a mistake.

Try this program to get get a message that would not be generated if
'use strict' was not used;

=========================

#!/usr/bin/perl

use strict;

my $blah;

$blaj =2;

========================

You should also 'use warnings' as well. They all help




Owen
From: RedGrittyBrick on
On 16/02/2010 03:06, Robin wrote:
> I know this is a pretty stupid question, maybe, but is it better to
> use strict?

Yes. I try to make all my (multi-line) programs start

#!/usr/bin/perl
use strict;
use warnings;

> I have never gotten a concise answer to this question
> because there reallty isn't any docs on it.

The subject is discussed in this newsgroup surprisingly often.

There seems to be a strong consensus for strict and warnings. There is a
respected minority (possibly just one) who argue that `-w` is better
than `use warnings`. Unless you have read and understood the discussion
(and how it applies to your current project) you should 'use warnings'.
From: Patrick H. on
On Feb 15, 9:06 pm, Robin <rob...(a)cnsp.com> wrote:
> I know this is a pretty stupid question, maybe, but is it better to
> use strict?

I like it because it makes me be constantly aware of scope since I
have to consciously define everything somewhere. That can only help as
your program code gets longer.

Patrick