Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Best ways of learning Perl!

by jethro (Monsignor)
on Apr 12, 2010 at 09:32 UTC ( #834220=note: print w/ replies, xml ) Need Help??


in reply to Best ways of learning Perl!

Usually people fall into two categories: visual learners and oral learners. You might be in the second category, in which case it could help to find a local perl course (usually not available) or someone with perl knowledge to talk to (chances pretty good). At least if you are in or near a bigger city you should be able to find a perl user group (for example "perl mongers"). Whether you get someone to help you is dependant on your social skills ;-)

Independent from that the best way to learn any programming language is to write small programs yourself, as previous posters already mentioned. But for that one important piece of knowledge (that beginner books strangly never seem to impart) is how to debug. It is rather trivial knowledge, but most things are after you know them. And while debugging you learn the most about a language

When you write programs, even really small ones, you will produce bugs and your program will produce surprising output. If it is a syntax error it is easy, just read the error message for hints where to look. But if your program just does something strange or loops endlessly or just hangs, what do you do?

Simple, you check what your program is doing in detail by adding print statements. Statements like print "start of loop 1\n" will tell you the order in which your program is executed. Statements like print "counter is $counter\n" will tell you the contents of variables at critical points in your program. Don't assume anything, check what you believe to know

Perl can help you with debugging. Always write "use warnings;" and "use strict;" at the start of your scripts. Strict mode may seem like a hassle (basically you have to declare every variable with 'my' the first time you use it), but it is worth it in the long run.

If you further add "use Data::Dumper;" you can always print out variable values with print Dumper(\$counter); in much more detail, very helpful with arrays and hashes.


Comment on Re: Best ways of learning Perl!
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2014-11-26 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (165 votes), past polls