Why, why, why, -w and use strict? 
Author Message
 Why, why, why, -w and use strict?

I learned perl mostly from a book "PERL and CGI for the WWW" by Elizabeth
Castro, and it only recomends using taint checking and only for some
scripts.

Why is it a big deal to be forced to predeclare any variables?  If not
declaring them saves a line of code, doesn't that help?

The faq tells me -w turns on warnings to help with debugging.

Once your script was working, wouldn't removing them speed things up a bit?
Or why even use them unless the script isn't working to begin with.



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

:I learned perl mostly from a book "PERL and CGI for the WWW" by Elizabeth
:Castro, and it only recomends using taint checking and only for some
:scripts.  Why is it a big deal to be forced to predeclare any variables?
:If not declaring them saves a line of code, doesn't that help?  The faq
:tells me -w turns on warnings to help with debugging.  Once your script
:was working, wouldn't removing them speed things up a bit?  Or why even
:use them unless the script isn't working to begin with.

You'll get a real answer when I see a real address.

--tom
--
Today I dialed a wrong number...The other person said, "Hello?" and I said,
"Hello, could I speak to Joey?"...
They said, "Uh...I don't think so...he's only 2 months old."
I said, "I'll wait."  -- Steven Wright



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

Quote:
> I learned perl mostly from a book "PERL and CGI for the WWW" by Elizabeth
> Castro, and it only recomends using taint checking and only for some
> scripts.

> Why is it a big deal to be forced to predeclare any variables?  If not
> declaring them saves a line of code, doesn't that help?

> The faq tells me -w turns on warnings to help with debugging.

> Once your script was working, wouldn't removing them speed things up a
bit?
> Or why even use them unless the script isn't working to begin with.

I'd be a little careful about the book from Elizabeth, she is one of those
who recommends installing your Perl.exe in the cgi-bin directory.

Wyzelli



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

Quote:

>I learned perl mostly from a book "PERL and CGI for the WWW" by Elizabeth
>Castro, and it only recomends using taint checking and only for some
>scripts.

>Why is it a big deal to be forced to predeclare any variables?  If not
>declaring them saves a line of code, doesn't that help?

Shorter scripts are not necessarily better.  All other things being
equal, shorter scripts are better, because they're easier to read; but
in some cases, the benefits of doing something exceed the drawbacks of
making your script longer.

Several things are better about use strict 'vars':
- 'my' variables don't get dynamic scoping.  This is a Good Thing.
  Your scripts will be much easier to debug if you don't have variables
  with dynamic scoping in them.
- If you misspell a variable name when you're trying to read it, you
  will end up reading an undefined value.  If you misspell it when you're
  trying to write it, you will end up writing someplace that never gets
  read.  Either way you have introduced a bug into your script.  use strict
  'vars' keeps you from doing this by accident.
- If you accidentally try to read or write a variable outside the part
  of the script where it's used, use strict 'vars' will often catch this
  -- the lexical scope of the variable will not extend that far.  This
  isn't much of an advantage in my experience; nine times out of ten I
  end up moving the variable declaration so its scope is bigger.

Quote:
> The faq tells me -w turns on warnings to help with debugging.

> Once your script was working, wouldn't removing them speed things up a bit?
> Or why even use them unless the script isn't working to begin with.

Well, if you are confident that your script is completely bug-free,
then removing -w might be harmless.  (I don't know whether it speeds
things up or not.)

If you are confident that your script is completely bug-free, one of
the following must be true:
- it's a very short script.
- you've really spent a lot of time checking it and having other people
  check it -- a day or so per five lines.
- you're a much, much better programmer than I am, for whom mistakes
  are so rare that you don't need the safeguards of -w.
- you're an inexperienced programmer who hasn't yet learned how many
  mistakes he really makes :)

I suspect the last.  Me, I take all the help I can get for finding
errors in my programs.  -w has saved my {*filter*}more than once.


you're a total lame loser.

Kragen
--

Wed Sep 08 1999
61 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL: http://www.*-*-*.com/ ~kragen/bubble.html>



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

Quote:


> > I learned perl mostly from a book "PERL and CGI for the WWW" by Elizabeth
> > Castro, and it only recomends using taint checking and only for some
> > scripts.

Does she really use all caps for `PERL'?  <sigh>  At least she
recommends taint checking I guess.

Quote:
> > Why is it a big deal to be forced to predeclare any variables?  If not
> > declaring them saves a line of code, doesn't that help?

It doesn't always save a line of code since you can declare and define
them together on one line.  The idea isn't necessarily to write the
shortest possible script, but generally to write the most efficient
and maintainable one.  By scoping your variables you prevent many
common errors.

You may know which variables you are using in your script (perhaps),
but what if you start including modules (including your own)?  What if
you assume that a variable is undefined (zero), not realising that it
was used globally and already contains a non-zero value?

use strict also provides many other benefits.  Sometimes you don't
want all of the restrictions.  In these cases specify which stricts
you do want (refs, vars, subs).  

Quote:
> > The faq tells me -w turns on warnings to help with debugging.
> > Once your script was working, wouldn't removing them speed things up a
> > bit?

Then everytime you change your script you would need to run it again
with -w to check for compile-time warnings.  Even allowing for that,
what about run-time warnings?  See perldoc perldiag for some examples.

Quote:
> > Or why even use them unless the script isn't working to begin with.

How do you know that your script isn't working?  Many bugs are
difficult to spot in the generated output from complex programs.

Cheers,
Andrew



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


<snip>

Quote:

> you're a total lame loser.

My ISP recommended using a phony address when posting to newsgroups because
he says it cuts down on spam.

The only moderator that even mentioned anything about it said he didn't mind
the address because he could still track me down and complain to my ISP from
the info in the message header.

I dont mind being thought of as a lame loser if it slows down the spam some.
And since I read the newsgroups for the replies, my email address isn't
needed.



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


<snip>

Quote:

> you're a total lame loser.

My ISP recommended using a phony address when posting to newsgroups because
he says it cuts down on spam.

The only moderator that even mentioned anything about it said he didn't mind
the address because he could still track me down and complain to my ISP from
the info in the message header.

I dont mind being thought of as a lame loser if it slows down the spam some.
And since I read the newsgroups for the replies, my email address isn't
needed.



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

<URL::">
``


`` <snip>

`` > you're a total lame loser.
`` >
``
`` My ISP recommended using a phony address when posting to newsgroups because
`` he says it cuts down on spam.

So, you let the spammers win? How much spam do you really get? Is it really
worth faking your address? Do you walk outside wearing a ski mask as well?

`` The only moderator that even mentioned anything about it said he didn't mind
`` the address because he could still track me down and complain to my ISP from
`` the info in the message header.

This group doesn't have a moderator.

`` I dont mind being thought of as a lame loser if it slows down the spam some.
`` And since I read the newsgroups for the replies, my email address isn't
`` needed.

Have fun reading then. I certainly won't answer your postings. In fact,
I'll just killfile you.

Address mungers are lusers.

Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))

  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Quote:
> Bart Simpson explains it all:

> :My ISP recommended using a phony address when posting to newsgroups
because
> :he says it cuts down on spam.

> Bad advice.

Why?  If spammers search newsgroups for e-mail addresses, then it will cut
down on spam.

Well here is my real e-mail address.  I'm not really Bart Simpson. (but you
knew that)

Just so you know, I'm not switching to my real address just to stay out of
Abigale's killfile.  The only time she posts anything is to tell people
they're idiots and/or adding them to her killfile.



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?

Quote:

> My ISP recommended using a phony address when posting to newsgroups because
> he says it cuts down on spam.


and the people at nospam.com won't be happy with you using it.

People will want to reply by mail sometimes; I hate sending this
to the group, because this isn't about Perl. Helping people
is much more important than not having to delete two or three
spam mails per day.

Your ISP is clueless.

(yes, my From: address does say "spamtrap", but it still works).
--

   This is no way to be
     Man ought to be free      -- Ted Bundy
       That man should be me



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Quote:



> <snip>

> > you're a total lame loser.

> My ISP recommended using a phony address when posting to newsgroups
because
> he says it cuts down on spam.

> The only moderator that even mentioned anything about it said he
didn't mind
> the address because he could still track me down and complain to my
ISP from
> the info in the message header.

> I dont mind being thought of as a lame loser if it slows down the
spam some.
> And since I read the newsgroups for the replies, my email address
isn't
> needed.

Why don't you sign up for a web-based email account like the one Deja
News offers. You get access to newgroups archives as well as a separate
email address where you needn't worry about spam.
--
Douglas Sparling
Web Programmer
Universal New Media
http://www.uexpress.com

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Wed, 18 Jun 1902 08:00:00 GMT  
 Why, why, why, -w and use strict?


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. why o why o why

2. Pattern-matching wackiness: why, Larry, why?

3. Pattern-matching wackiness: why, Larry, why?

4. use strict: why?

5. Why use strict?

6. works without strict but not with why ????

7. why not use(strict)?

8. why does strict not warn about shaddowing declarations ?

9. Ever Wonder Why Not Everyone Uses Modules?

10. O_OBJECT uses warn() not croak(), why?

11. Why does using index() outside loop slow down loop

 

 
Powered by phpBB® Forum Software