Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Best ways of learning Perl!

by Tea (Initiate)
on Apr 12, 2010 at 05:40 UTC ( #834190=perlquestion: print w/replies, xml ) Need Help??

Tea has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I was wondering which is the best way to learn Perl? I always read slowly through books and online e-books that guide you through the process and I'm not seeming to grasp it properly. I've purchased books to help me but still I struggle to take it in. I'm highly intersted in Perl as a language and do put in the effort to learn but I don't know which way to go about it. Should I take in small portions and keep revising over it until I get the hang of it? I'm not sure, any expierence of how you did it would be greatly appriecated

Replies are listed 'Best First'.
Re: Best ways of learning Perl!
by Ratazong (Monsignor) on Apr 12, 2010 at 06:30 UTC

    Starting step-by-step is a good approach. When I started, I focused on working with files and applying regular expressions to extract relevant information. And I didn't bother much that all my control-structures looked like c. Afterward I played with hashes and then with Win::OLE and Excel - just because that were the things I needed most.

    A great way to learn is also the monastery: I often use the questions by other monks as a challenge to produce some working code. And afterward I compare my solution with the highly optimized ones of the more experienced monks here. And try to understand their solutions. I think I learned very much that way. And if I look at (perfectly working!) code I wrote some months ago, I see a huge difference in style and efficiency. :-)

    If you want a collection of good exercises and other information for a beginner, you may also have a look at the following great collection by planetscape: Re: Real Life Perl Exercises.

    HTH, Rata
Re: Best ways of learning Perl!
by moritz (Cardinal) on Apr 12, 2010 at 06:16 UTC

    Reading books alone won't be enough - you have to actually write perl code, and try out the things you've read about.

    The best thing you can do is write some small programs that you actually use, and improve them over time. If you're stuck with certain specific questions, come here and ask them.

    Perl 6 - links to (nearly) everything that is Perl 6.
      I shall do that. May I reply even though it may seem silly to ask?
        Sure. We are always glad to help, even if the question might seem silly to somebody.

        The only questions we don't like here are those where the poster didn't put any effort in finding out the answers himself.

Re: Best ways of learning Perl!
by jethro (Monsignor) on Apr 12, 2010 at 09:32 UTC

    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.

Re: Best ways of learning Perl!
by eyepopslikeamosquito (Bishop) on Apr 12, 2010 at 07:19 UTC
Re: Best ways of learning Perl!
by JavaFan (Canon) on Apr 12, 2010 at 09:12 UTC
    Hi, I was wondering which is the best way to learn Perl?
    That depends on 1) what you already know, 2) you (different people learn things in different ways), 3) what you find "best".

    For some values of "best", the best way to learn Perl is to first learn Unix, C, and shell scripting.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://834190]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2021-01-26 09:27 GMT
Find Nodes?
    Voting Booth?