There's more than one way to do things | |
PerlMonks |
Re: program doesnt work for all elements of the arrayby talexb (Chancellor) |
on Oct 18, 2013 at 13:28 UTC ( [id://1058757]=note: print w/replies, xml ) | Need Help?? |
This is going to sound old-fashioned, but I'd recommend you spend some time in the Perl debugger. You can try out individual syntaxes, dump out variables, and get a feel for the language. For example, you have syntax like @words1$a = $name;; it looks like you're trying to add $name to the words1 array at index $a. You haven't done this before, because that's the wrong syntax; and in any case, push is normally used to add elements to an array. Also, $a and $b are special variables used only in sort blocks -- it's not forbidden to use them, but it's considered bad style. It's also handy to write yourself a comment or two so you have a good idea of what each piece of code is supposed to do. This will also help others understand what the code is meant to do. O'Reilly's Learning Perl is a great starter book for this language.
In Section
Seekers of Perl Wisdom
|
|