That's a much better example. It seems obvious to me,
but I can easily see how it might not be obvious to people
who don't cringe when they read "recieved". More
importantly, warnings will indeed not catch it. Of course,
this means typoing the same variable in the same way more
than once... so it still seems somewhat unlikely to me.
But it's undeniably a possible scenerio.
I should also note that I have always been in favour
of using strict in files that get used or included by
other files; it was the value of using it in a regular
script that I wasn't seeing.
And yes, I have worked with code that spans multiple
files and ten thousand plus lines and uses global
variables (though not in Perl, and I did not use
globals anywhere near exclusively). The trouble I
eventually ran into was not because of this, but
because the version of the language and compiler that
I had been using had limits on how large the program
could be, and when I reached those limits I had to try
to port it to the newer version, which proved difficult,
and I set it on the back burner. I've also worked with
Emacs lisp, which does not have lexical scoping as far
as I know (in any event, it is not much used) but solves
the namespace issue another way (by making variable names
longer; the convention is to prefix your names with the
name of your package). It is actually important in Emacs
lisp that many variables be global, because you
specifically want other code to be able to dynamically
scope your variables and thus alter your behavior when
it calls you. It is impolite to setq another package's
variable in most cases (except from .emacs of course),
but you let it as a matter of course. (let in lisp is
like local in Perl; AFAIK there is no equivalent to my,
nor is it missed.) Then there's buffer-local...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||