That's very similar to a situation I was thinking about, except that I would have stated it more generally: I would consider (locally) using symbolic references in a scenerio when they would be convenient and the risk would be checked by having the complete list of possible values of the reference ennumerated en toto in the code. Additionally, I never bother with strict for very short use-once scripts (e.g., anything I type at the command line after perl -e).

Truthfully, I don't always use strict in other cases either, but I'm starting to do so more often that I used to do. I'm up to the point of using at the top of all files that get included by another file now, which is progress... and for the record I have yet to see strict catch a mistake that warnings missed, except in a conversation on Perlmonks where a monk contrived an example for me to demonstrate how it could happen. However, the example (though contrived) was sound and I've taken it to heart somewhat.

And that's why I don't think question 2 as it stands will get the information the test writer actually wants. I would have no trouble explaining the value of strict at this point, but I don't yet have a firm habbit of always using it, which is what the test really wants to know. (The best way to find out? Have 'em write a section of code to do some simple task and see if they declare all of their variables.)

Actually, my biggest problem with strict is that it doesn't test what I want it to test: whether a subroutine tromps on a (possibly lexical) variable from outside the subroutine. This is for me a *way* more likely scenerio than the ones strict does check.


{my$c;$ x=sub{++$c}}map{$ \.=$_->()}map{my$a=$_->[1]; sub{$a++ }}sort{_($a->[0 ])<=>_( $b->[0])}map{my@x=(& $x( ),$ _) ;\ @x} split //, "rPcr t lhuJnhea eretk.as o";print;sub _{ord(shift)*($=-++$^H)%(42-ord("\r"))};

In reply to Re: Not strict by jonadab
in thread A Perl aptitude test by Jonathan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.