Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: program doesnt work for all elements of the array

by talexb (Canon)
on Oct 18, 2013 at 13:28 UTC ( #1058757=note: print w/ replies, xml ) Need Help??

in reply to program doesnt work for all elements of the array

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.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Comment on Re: program doesnt work for all elements of the array
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058757]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2016-05-05 08:21 GMT
Find Nodes?
    Voting Booth?