On Sun, Dec 28, 2008 at 12:25 PM, sawyer x <[email protected]> wrote: > I don't think this is too difficult to explain. > > The problem lies in the mistake of trying to do an action on one that > does not receive such action. > They want to split an array. You cannot split an array, an array is > already split. You want to split a string. This could have simply been > a typo. If they would, for instance, do (under vim) :%s/@argv/$argv/g > everything would be okay.
To put slightly more context on the example, the actual code was trying to split @ARGV. So the person who wrote this - and I've already encounter this many times - has not yet clearly understood that the things he types on the command line are already separated into distinctive elements and are placed in @ARGV. Usually they write such code after I teach them about arrays, the command line and @ARGV but *before* I teach about context. So I cannot really explain the problem by the context. At least not during the exercise. It is also slightly irrelevant as what the students should really understand is the conceptual reason why you cannot split an array: The best explanation I read in this thread was the "You cannot split an array as it is already split" and that "you are trying to do an operation (split) on something that cannot be split (an array)". Thanks for the responses. Now to put this mail even further in context I have been planning to add a "beginner mode" to Padre where it would catch such bugs. We have a ticket http://padre.perlide.org/ticket/52 for this on Padre and I have just committed the first implementation of this catching the above described case. regards Gabor _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl
