use strict...

Discussion in 'Perl Misc' started by Robin, Feb 16, 2010.

  1. Robin

    Robin Guest

    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
    Robin, Feb 16, 2010
    #1
    1. Advertising

  2. >>>>> "Robin" == Robin <> 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
    <> <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
    Randal L. Schwartz, Feb 16, 2010
    #2
    1. Advertising

  3. Robin

    Owen Guest

    On Feb 16, 2:06 pm, Robin <> 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
    Owen, Feb 16, 2010
    #3
  4. 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'.
    RedGrittyBrick, Feb 16, 2010
    #4
  5. Robin

    Patrick H. Guest

    On Feb 15, 9:06 pm, Robin <> 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
    Patrick H., Feb 16, 2010
    #5
  6. Robin

    Guest

    On Sun, 21 Feb 2010 11:22:31 -0600, Tad McClellan <> wrote:

    [snip]

    >Since Robin (and, I assume, you) do not know why you would _not_ use strict,
    >you _should_ use strict. :)


    Then it might be better to know circumstances one wouldn't use strict in
    relation to vars, subs, refs, performance, debug, production, bugs, versions,
    etc ... There has to be a starting point for full understanding.

    -sln
    , Feb 22, 2010
    #6
  7. Robin

    Steve Guest

    On Feb 15, 7:06 pm, Robin <> 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


    I've been reading the oreilly book on perl and it says to always use
    warnings and strict. It can be a bit frustrating sometimes though.
    Like when your program will compile without using strict and won't
    when you use it :p. But that's what it's there for! To make sure you
    do things right!
    Steve, Feb 24, 2010
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H. Wade Minter
    Replies:
    8
    Views:
    292
    Robin
    Apr 25, 2004
  2. Martina

    why is important to use : use strict?

    Martina, Sep 19, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    99
    Jürgen Exner
    Sep 20, 2005
  3. Ting Wang
    Replies:
    5
    Views:
    173
    John Bokma
    Oct 6, 2005
  4. Peng Yu

    When to use "use strict;"?

    Peng Yu, Jan 25, 2010, in forum: Perl Misc
    Replies:
    14
    Views:
    176
    John Bokma
    Jan 27, 2010
  5. Marius Gavrilescu

    Re: use strict; use warnings;

    Marius Gavrilescu, Feb 24, 2014, in forum: Perl Misc
    Replies:
    152
    Views:
    501
    $Bill
    Mar 11, 2014
Loading...

Share This Page