Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • What I guess James doesn't know, or doesn't realize, is that in the case of @, % and $, they are actually meant to *help* readability. If a newb sees @, he knows it's an array. If he sees %, he knows it's a hash, etc.

    To an extent, this is very true. If you have some experience programming.

    But, if you don't have any/much experience programming... then this gets very confusing:

    $hash{element}

    Because a newbie sees the sigil and thinks: scalar

    Then along comes:

    $hash

    And he thinks: same scalar

    And it takes

    • But the sigil is right: $hash{element} and $hash are both scalars. I don't have a huge issue teaching this because most people get it once they know the rule: $ is one thing, @ can be many things, and % is a hash. I emphasize those points, and it works.

      Most people we teach don't get $hash and $hash{element} confused either. One doesn't have a curly brace after it. This is another thing we emphasize, and we find it very easy to teach.

      I can see the problem for people who teach themselves Perl from the
      • Most people we teach don't get $hash and $hash{element} confused either. One doesn't have a curly brace after it. This is another thing we emphasize, and we find it very easy to teach.

        Yep. Makes perfect sense to me. I agree totally.

        But... I've got some customers that, after a week, still couldn't tell the difference between those two variables. They (mostly) get the scalar / hash thing... and getting an element of a hash.

        But as soon as you give them (the scalar and the hash) both the same name, they freak when they need to get one of the hash elements.

        I think that the problem is that I'm trying to teach people that have absolutely zero experience programming any language. And they don't do programming as a routine part of their job, or as a hobby. (Can you say "public school teacher"?) Great people. Not technically inclined.
        • Well, we explicitly tell them that you can have different variable types with the same name. When we introduced arrays and hashes, we hammer this into their heads.

          You already know they are going to have trouble with that stuff, so you head it off before they have a chance to get confused. :)