Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: program doesnt work for all elements of the array

by talexb (Chancellor)
on Oct 18, 2013 at 13:28 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found