Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Strict isn't strict enough

by BrowserUk (Patriarch)
on Dec 31, 2011 at 16:38 UTC ( [id://945751]=note: print w/replies, xml ) Need Help??


in reply to Strict isn't strict enough

If you'd typed

$slave::tyop = "Hello world"; print "$slave::typo\n";

You'd've gotton 3 warnings:

Name "slave::typo" used only once: possible typo at -e line 1 Name "slave::tyop" used only once: possible typo at -e line 1 Use of uninitialized value $slave::typo in print at -e line 1

As is, you've used it twice and spelt it the same both times. That a pretty clear indication that you are doing it intentionally.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Strict isn't strict enough
by davies (Prior) on Dec 31, 2011 at 16:43 UTC

    Agreed, but in more complicated code it may be the result of a single typo being cut & pasted. I have the scars.

    Regards,

    John Davies

      *ANYTHING* can be typoed, and then cut-and-pasted. If your coding style is to randomly hit the keyboard, and then ask perl whether you did a good job, don't expect use strict; to be a silver bullet.

      Perhaps you should replace /usr/bin/perl with

      #!/usr/bin/sh echo "Possible typo detected at line 1. Please fix." exit 1
      BTW, what should perl do if you did my $hwatever and then cut-and-pasted the $hwatever?
        what should perl do if you did my $hwatever and then cut-and-pasted the $hwatever?

        Give a compile time error when I use $whatever. Obviously it isn't a problem if the same typo is used throughout, but if a variable can be used in two places then there is scope for typos that I expected strict to catch before I read the docs. I still want to catch it if I can.

        Regards,

        John Davies

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://945751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found