Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Small Perl quests for a beginner?

by matze77 (Friar)
on Dec 03, 2008 at 07:55 UTC ( [id://727606]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Fellows!
I wonder if you know of any small quests which would be suitable for a beginner, for practicing?
If you know of a site or a small problem which would be fine for Perl ...
e.g.: get used to variables, use loops, scalars ...

It is more fun to have a (not too much challenging) "problem" to solve than some hypothetical case.

Thanks for your help!

As a longterm project i want to start a match schedule calculation but thats too much for my current knowledge

Update:
Some Suggestions:
Do the exercises in the Lama Book
Do some simple exercises on the new learned stuff
Help at CPAN projects (testing)
Try to answer the questions in SOPW

direct links to answers:
Some Exercises:Re: Small Perl quests for a beginner?

Again i thank you all for your very helpful suggestions!.
/Update

Replies are listed 'Best First'.
Re: Small Perl quests for a beginner?
by moritz (Cardinal) on Dec 03, 2008 at 08:33 UTC
    There's Ninety-Nine Prolog Problems, many of which are equally interesting for Perl programmers. The difficulties range from "trivial" to challenging.

    Update: here's another one: Rosetta Code. It's a collection of common programming problems, with solutions in many programming languages. If you look a the problem first, and not at the solutions, it is another good set of exercises. (Sadly I haven't found a list of problems sorted by difficulty).

    Both of these collections do not focus on perl specific tasks like text processing, though.

Re: Small Perl quests for a beginner?
by jbert (Priest) on Dec 03, 2008 at 09:28 UTC

    If you have an interest in mathematics, Project Euler offers a large number of programming problems.of varied difficulty.

    If you feel like a challenge, you could try to go through some of the exercises in SICP. The book is based around scheme, but there are still a number of good problems in there you could pick out. There's a reasonable chance of going down some blind alleys tho (e.g. scheme has tail recursion and I don't know that perl does, so some sections which take advantage of that might blow up on you), so take that recommendation with a pinch of salt.

    Edit: updated broken link. D'oh. Thanks for correction.

      Your link points to a different page on Perlmonks, but that page gives a 404. I did find another Project Euler site though.
        That's the one. Sorry for the broken link, fixed now.
Re: Small Perl quests for a beginner?
by trwww (Priest) on Dec 03, 2008 at 11:52 UTC

    Hello,

    The exercises at the end of each chapter in the Llama Book are excellent. If you can complete those sucessfully without too much trouble you should be able to figure out how to build your app.

    have fun,

      I agree. The Llama book is by far the best Perl book I have read and the practice exercises are pretty challenging for a beginner. I am grateful to Randal for the awesome book.
Re: Small Perl quests for a beginner?
by DStaal (Chaplain) on Dec 03, 2008 at 14:14 UTC

    If you are interested in something 'useful', instead of just solving book-problems, try browsing CPAN and looking for modules in need of sub-classes. There are quite a few modules that are made to work with various logs/wikis/programs, etc, that could always use more plugins for translating to whatever you happen to be conversant in. Putting together a plugin, as well as a test suite and module packaging for one, will show you around more than just the language, but also the culture and tools of Perl. Most of the time the authors of the base classes have put some thought into making subclasses easy and clean to make.

    And, if you get stuck, the author of the original base will probably be willing to help you (especially if you show you are trying!). They'd probably be flattered. (I know I would. ;) ) Even if you don't want to set up a CPAN id, they'd probably upload it for you if you can provide something that works.

    Projects off the top of my head that could use such include Pod::Simple::Wiki and <shameless_plug>Mail::Log::Parse</shameless_plug>. I'm sure there are others.

    And in the end you'll have the satisfaction of having written something people actually use!

Re: Small Perl quests for a beginner?
by perreal (Monk) on Dec 03, 2008 at 16:47 UTC
    For me the best quests are automating things you regularly do like checking, forwarding emails, parsing certain web pages for certain things and sending emails to your account when something of interest comes up. I always find ideas to make life easier for me and make a project out of it.
Re: Small Perl quests for a beginner?
by InfiniteSilence (Curate) on Dec 03, 2008 at 17:21 UTC
    Don't go around studying contrived examples online to learn Perl. One of the best ways is to try to gain XP here at Perlmonks by answering questions. You will get shot down at first, sure, but if you keep getting back up and reading the right books and perldocs you will gain proficiency fast.

    The reason this is better than contrived examples is that it is pretty humbling to see the dozens of questions asked here daily that you can't answer. It keeps you learning -- not just about Perl but about computing in general. Overall, you are in the right place.

    Celebrate Intellectual Diversity

      There's one downside with this approach: many questions that a beginner could answer with his Perl skills are ambiguous and lack context to resolve the ambiguity.

      Usually you don't have this problem with "contrived examples", as you call them, and neither with real-world problems. But for beginners it's often hard to judge if a problem can be solved with reasonable effort. Which is why they go back to "contrived" problems.

      (I don't want to discourage anybody from answering questions here; I merely think that it's not the best way for the average beginner).

        Actually that's not a downside! PerlMonks SoPW provides a pretty fair slice of how information is presented in the real world. Very often "programming" problems aren't, they are really problems elucidating the actual problem then solving that (which often is fairly trivial).

        Following along on the process of digging out the information needed to describe a a problem then solving it is not at all a bad way of seeing how that process works (or doesn't work). Writing the code to solve the problem then comparing it to the (often) many answers provided by others with a range of skills using a variety of techniques provides much better insight than the (generally) single "answer" provided in a book or similar resource. Being able to follow up a solution with questions about how and why makes learning in the PerlMonks context way more effective than any formal self study course or even than many class.


        Perl's payment curve coincides with its learning curve.

      Most times, any question that is within my grasp has already been answered by another monk with a more complete answer than I could produce.

      That said, I do like to go down the list of SoPW questions, answer them to myself, and then see what the other monks have said. This often illuminates different ways of thinking about or attacking the problem, which is useful.

      The diversity of answers is one of the best things about PerlMonks, along with the diversity of questions. While this may be a bit overwhelming for a beginner, learning what the possibilities are and how to choose between them is very valuable. Many of the questions are very much beginner questions and many of the answers are written to be helpful to beginners. It is definitely not a site for experts only, IMHO.

      As, in the long run, success in programming is as much about communication as it is about variables, data structures and algorithms (think of teams and long term code maintenance), it is also very instructive to see and understand the diversity of perspectives, expressions and communication styles. Often excellent guidance is offered explicitly, and the questions and answers are almost always interesting examples in practice. Small misunderstandings can lead to confusion, but this also is instructive, particularly if you take the time to follow the discussions to see how the misunderstandings are overcome, and usually they are overcome.

      Trying to understand the questions, including the poorly expressed questions, will help you learn how to ask your own questions more effectively, and this also will help you get the help you need.

Re: Small Perl quests for a beginner?
by pmonk4ever (Friar) on Dec 03, 2008 at 18:32 UTC
    Yes, matze77, in the Tutorials section there is an abundance of interesting and challenging reading and examples, and as always, you can download and tinker with the code to watch it do different things. :-)

    Also in your meanderings check out Cool Uses for Perl, many things to be learned there as well...

    As mentioned above, the Llama Book exercises are plenty challenging and they can be expanded as well.

    Remember, use warnings; & use strict; are your friends!!!

    When you get stuck, the debugger will come in handy to show you what is going on inside the script, which is usually NOT what you wanted to happen! :)

    ki6jux

    "No trees were harmed in the creation of this node. However, a rather large number of electrons were somewhat inconvenienced."

Re: Small Perl quests for a beginner?
by koolgirl (Hermit) on Dec 04, 2008 at 19:13 UTC

    Not to sound like a parrot, :), but the exercises in the llama book have helped me tremendously. Also, Every time you learn a new skill, write a small program, to play with and test that specific skill, i.e., when I learned regular expressions, I wrote this little reg ex tester:

    #!usr/bin/perl $my_string = ""; $my_regx = ""; # This program tests regular expressions against a match. if ($my_string =~ /$my_regx/x) print qq{Matched: "$&"\n}; # print match print qq~Before match: "$`"\n~; # print data before match print qq|After match: "$'"\n|; # print data after match } else { # do nothing } # end if print "Rockstar Programming Inc. All Rights Reserved\n";

    to practice and play around with regular expressions. The same thing for loops, if statements, sub-routines, variables, arrays, hashes, etc. This is a great way to learn, for several reasons,

    One, it teaches you the basic skill you're practicing;

    Two, you learn basic structure by having to design the little testers;

    Three, you learn how to break things into pieces and play with/work with them, which is a skill needed for de-bugging later, more complicated programs;

    And four, you can use these little testers you wrote for actually de-bugging your code later. :)

    P.S. Umm, the whole "Rockstar Programming" line, should probably be left out, that will only be applicable in the future after I've taken over the world with my software development company, Rockstar Programming ;).

Re: Small Perl quests for a beginner?
by zod (Scribe) on Dec 04, 2008 at 05:47 UTC
Re: Small Perl quests for a beginner?
by scorpio17 (Canon) on Dec 04, 2008 at 22:13 UTC

    Here's a suggestion if you're interested in web-related perl projects: there was a nice intro to Ruby a couple of years ago here:

    Rolling with Ruby on Rails

    Even though this article is on Ruby, it's very well written and it introduces a good sample problem: build an online cookbook (i.e., an online recipe database). You want to be able to create new recipes, modify old ones, view them, search them, etc.

    While it seems simple, by the time you work through it you'll have a good understanding of perl, as well as mysql, apache, linux (the whole LAMP stack).

    Now, the point of the original article was that you could do this in about 20 lines of ruby... nevermind all that! You can do something comparable using Catalyst. But as a beginner, I suggest doing it the hard way with CGI::Application, because it will help you understand all the nitty-gritty details. You can always do a "version 2" in Catalyst later. That will really help you understand and appreciate what all a web framework does for you "under the hood".

Re: Small Perl quests for a beginner?
by choroba (Cardinal) on Jun 07, 2013 at 18:39 UTC
    Two more sites with exercises with no language restrictions:

    Rosalind
    Contest Coding

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://727606]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-29 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found