in reply to Re: Finding the total number of elements in an array.
in thread Finding the total number of elements in an array.

I somewhat agree with you: I don't want PerlMonks to start being flooded with the same basic questions over and over.

However, Almost All questions about Perl syntax and things like this, even the confusing ones, can validly be answered with "RTFM." This doesn't mean that the answer in the manual is adequate to answer someone's question. It also implies that the asker knows where the manual is.

For example: if you were to tell a perl newbie with experience programming in C, "RTFM: It says right here, evaluate the array in a scalar context to get its length," that may be No Help At All, since context is a completely foreign concept to many C programmers.

I think a better attitude to take would be to reinterpret "How can I <basic syntax issue>" as "Where is the documentation for <basic syntax issue>?" If you teach the person where to find the answer, instead of telling them they shouldn't have asked the question, then maybe they will read the manual before posting in the future, now that they know where it is.

If you don't want to waste your time answering the question, don't do it. There are other monks less experienced than you who would be happy to help.

That said: there is a good answer to this question in the categorized Q&A section of Perl Monks as well: How do I find the size of an array?

As for array lengths: often you don't need them at all. If you're planning to loop over the elements of an array, often it's better practice to use a foreach style loop than a c-style loop:

my @array = qw(a few items in the array); foreach my $element (@array) { do_something_with($element); }
Alan

Replies are listed 'Best First'.
RE: RE: Re: Finding the total number of elements in an array.
by eduardo (Curate) on Jul 19, 2000 at 19:49 UTC
    bravo. i see your point, and you have a very compelling argument. it's often times hard to remember what it's like to know that the answer is plain and simple and there... yet for some reason, you can not find it. so, my suggestion is, maybe there should be a multi-channel setup, whereby some group of users are able to rate a question on the level of knowledge required to answer such a question? a question like this would have a rating of novice, and therefore anyone who was too damned high and mighty (making fun of myself here...) to answer novice questions, ('cause you know, we'd never been novices :) ) would just be able to ignore them...