You know how rules of thumb work pretty well, don't they? Otherwise they wouldn't qualify, right? There's a large population of problems that conform to the rule.

Same way with stereotypes. Stereotypes come into existence because someone noticed a correlation. Upon commenting on this correlation (real or not), other people notice it until it propagates onto comedy shows (where hopefully their true nature is revealed).

Knowing the real wisdom embodied in a rule of thumb is real knowledge. Blindly following it is real dumb. I submit this example for your review:

use strict; use warnings; use Getopt::Declare; # all reference variable names declared above this line my $option_spec = qq{ Version: $VERSION Description: $SCRIPT_NAME reads a related set of Agilent ".dlog" files and genera +tes the equivalent set of Genesis input files. Options: -$SPLIT_MAP_FILE_PARM <$SPLIT_MAP_FILE_STRING> Name of the split +map file (no default) <${INPUT_FILE_OPT}:if>... One or more input files to process (wil +dcards may be used) [required] -$FORCE_OUTPUT_OPT Overwrite existing output files (default is to + abort when an existing output file is encountered) -$OUTPUT_DIR_OPT <$OUTPUT_DIR_PARM> Put output files in this dire +ctory, create the directory if it doesn't exist (default is current d +irectory) -$OUTPUT_PREFIX_OPT Prefix for naming all output files (default: + $OUTPUT_PREFIX_DEFAULT) -$OUTPUT_SUFFIX_OPT Sufffix for naming all output files (default: + $OUTPUT_SUFFIX_DEFAULT) -$VERBOSE_OPT Enable verbose info Example: Run $SCRIPT_NAME with split map RV900_split_map, verbose info, and u +se output prefix "RV900", and process all *.dlog files in the current + directory: $SCRIPT_NAME -$SPLIT_MAP_FILE_PARM RV900_split_map -$OUTPUT_PREF +IX_OPT RV900 -$VERBOSE_OPT *.dlog } my $options = Getopt::Declare->new( $option_spec ) or die "\n**** Error processing command line options, terminating $S +CRIPT_NAME\n";
which gives me something like this (though the line numbers are different, and my real code has all the other variables declared):
syntax error at xxx.pl line 37, near "my "
Of course, this was buried in with other errors and warnings. It took me a while to isolate, until I got my head on straight and started testing code snippets on their own. For the longest time I couldn't see that I needed a semi-colon after the closing brace on qq.

Somehow I had distilled down the general rule of "no semi-colon after a statement brace" to "no semi-colon after a brace", even though I know that doesn't work for hash elements.

So be careful with what you "think" you know, because you may not actually know it.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Rules of Thumb, Stereotypes, and other misleading "knowledge"
by BrowserUk (Patriarch) on Feb 07, 2006 at 05:07 UTC

    This is another reason why I settled upon qq[] q[] m[] s[][] as my prefered choice of balanced delimiters for quoted constructs. {} is already well overloaded in Perl.

    So be careful with what you "think" you know, because you may not actually know it.

    I completely agree with that. So much so, I even meditated upon it. It's very easy to fall into patterns of behaviour that overtime become your defacto, without ever quite realising why and how you arrived at them.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Rules of Thumb, Stereotypes, and other misleading "knowledge"
by GrandFather (Saint) on Feb 07, 2006 at 00:02 UTC

    Why not use a heredoc instead:

    my $option_spec = <<SPEC; Version: $VERSION ... $SCRIPT_NAME -$SPLIT_MAP_FILE_PARM RV900_split_map -$OUTPUT_PREF +IX_OPT RV900 -$VERBOSE_OPT *.dlog SPEC

    DWIM is Perl's answer to Gödel
      Why not use a heredoc instead:
      Yes, well, I had a good reason somewhere, I know I did, I just mislaid it.

      Actually, I always have to look up whether it's "<<HERE" or <<"HERE". And then there's the balanced delimiter aspect. So I've cornered myself into qq{...}, even though the terminator's not as obvious as HEREDOCs. (Vaguely reminds me of all that in-band/out-of-band signalling discussion.)

      But you're right, I should be more practical and simple, and less esoteric. I should use a bubble level instead of a laser sight, because last time I checked, it was pretty easy to use a bubble -- no batteries to run down, no beam to get in your eyes. If it's broken, it's pretty obvious.

      I think everyone should learn how to use a slide rule before they're allowed to use a calculator. Or an old fashioned manual typewriter before writing a letter on a computer. No one ever lost a day's work on a typewriter because of a power outage.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        Yes, well, I had a good reason somewhere, I know I did, I just mislaid it.

        Actually, I always have to look up whether it's "<<HERE" or <<"HERE". And then there's the balanced delimiter aspect. So I've cornered myself into qq{...}, even though the terminator's not as obvious as HEREDOCs. (Vaguely reminds me of all that in-band/out-of-band signalling discussion.)

        Ok, you had me up to here. I'm thinking, "This is a pretty good reminder to think outside of any box you've put yourself into." Then you go off in an undeserved (and off-topic) tangent. I'm curious as to what, precisely, you have to gain by giving such an absurd argument? Are you hoping to denigrate GrandFather's reasonable question, and thus, by extention, denigrate GrandFather for even asking it?

        If you think GrandFather is missing the point of your meditation, just say so. Don't belittle him with absurd strawmen as if he had brought those up, too.

        Personally, I don't think GrandFather missed the point at all. Even if he had, he was pointing out what he learned from the meditation, which is completely on topic.

        Remember: Quality isn't about fixing bugs, it's about preventing them. (Ok, that's a previous meditation of mine) And GrandFather is pointing out how to prevent this bug instead of remembering how to fix it.

        Meanwhile, even if you were using HEREDOCs, your point still stands for other common uses of braces - hash refs, eval blocks, anonymous subs, etc., as well as any less common ones, such as the delimiter to the quote operators (q, qq, qw, qx), or other short letter operators (m, s, y or tr).

        GrandFather was merely focusing on the one case you presented. Rather than belittle him for it, simply point out the other cases, and I'm betting GrandFather would just nod his head, say, "Oh, okay, good point," and we could continue in a civilised manner. He wasn't telling you your meditation was bad - just asking a legitimate question which deserves a legitimite answer. ("I forget why" counts, as does "I never remember the HEREDOC syntax")

Re: Rules of Thumb, Stereotypes, and other misleading "knowledge"
by ambrus (Abbot) on Feb 07, 2006 at 19:55 UTC

    I write condition() and do { ... }; too much to forget that sometimes I need a semicolon after a brace. However, I admit that I often forget the semicolon after class definitions in c++.