|No such thing as a small change|
The Big Testby japhy (Canon)
|on Oct 17, 2000 at 17:20 UTC||Need Help??|
There's obviously a reason there are 25,000 Perl help forums (whether it be a community, like PerlMonks, or just some messageboard). And it's not just because people are having trouble learning the language, although that is a big part of it. There are several problems that arise from trying to learn Perl:
Take the "how to get unique elements from a list" question. How would you do this as a human? If you can't answer that question, then chances are you won't be able to get Perl to do it for you. And even if you do, you probably don't know HOW Perl did it. So sit down, and think about it in human terms -- Perl might afford you a different approach, but at least be able to do the task in real life.
You (I, in this case) would go through the list of things and put all like things in respective piles. Then I would take one thing from each pile.
Or, I would take the things one at a time, and if I'd already put one in the "unique" pile, I wouldn't put it there a second time.
Those represent two different ways of approaching the problem as a human, and can be directly translated into Perl:
Sure, there are less compact ways of writing those, and you would probably not see these idiomatic methods right away, but the point is that you should be able to think in human terms and translate to Perl (if you can't already think in Perl ;)).
Which gets me to my main point. Patterns. If someone asks "how can I get the length of a string?", and you respond by telling them about the (poorly-named) length() function, and they ask how they use it... that's a case of a person not seeing a pattern. Have they never used a Perl function before? Do they not know how to look up a function for themselves?
Another example: someone wants to know how to arguments in a function. You tell them "the @_ array." They ask how they get arguments from it. It's just like any other array! (That's a little white lie, but nevermind.) Has the person never used arrays before? Do they not know how array indexing works (that is a HIGH possibility, seeing as how tons of people use @array[$x] when they shouldn't)?
Or here's a good one. "How do I tell if a number is even or odd?" I am not going to touch that one.
Ok, that's my rant. It boils down to my mantra. Programming is about finding patterns. That's the test.