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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
I'm wondering... (Score:1)
Here is why I ask...
I also had the problem (at first) with the array slice. I thought initially that it was a sigil issue and an issue with semantics. (As you have explained)
But, I noticed that I did not have the issue with a hash. It seemed to me that if the sigil was causing me to have a semantic problem that the problem would carry to other cases... but, in my case... it did not.
So, I thought about it some more. Then, I realized that I didn't have the issue with the hash because I would get an immediate error if I tried to do it with the hash.
But, I was NOT getting that kind of feedback with the array... because sometimes the thing "Just Works" like you want it to. Even tho you asked for something else... what you go was useful.
So, the "problem" got reinforced.
In the end, I solved it by thinking first about WHAT I wanted... I wanted a single scalar. Those are denoted by '$'. Next I think... OK, what is the name of the variable holding the data... then I'm done if the variable is in a scalar.
Or, I mentally treat the [] and {} as sigils to indicate that the variable HOLDING the data is an array or a hash.
(I'm sure someone is going to find a flaw in my thinking and really screw me up
Reply to This
Re:I'm wondering... (Score:1)
The
warningspragma catches this misuse nowadays, but many beginners either don't know about it or don't use it.Unfortunately, I didn't learn hashes until I had already familiarised myself with arrays, so I can't answer your first question.