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 a bit of work to explain that one $hash variable is different that the other $hash variable... because they both look the same to the untrained eye.

    And, while newbies probably shouldn't be spending too much time with references and objects... don't even get me started on this:
    $hash->{element}
    and
    $object->method
    So, as someone with a computer science degree... I wholeheartedly agree with what you are saying.

    As someone with a trainig background (military instructor)... and a consultant who has done some trainig to help others maintain code I've written... these are huge issues for newbies.
    • 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 fre
        • 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. :)