Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

seeking direction to start with perl

by jbakshi (Initiate)
on Feb 04, 2010 at 04:16 UTC ( #821312=perlquestion: print w/replies, xml ) Need Help??

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


I have already found a no. of good online books and tutorial for perl beginners. As I am a newbie I can't understand which is the best for me that's why I am seeking some suggestion from you the experienced monk.

I am familiar with shell script and I am looking for that domain of perl which can allow me to do sysadmin job more robustly with perl power as well as help me to design same (shell) script in perl.

BTW: any command to conver shell script to perl ?


Replies are listed 'Best First'.
Re: seeking direction to start with perl
by GrandFather (Saint) on Feb 04, 2010 at 04:44 UTC

    I presume you have already found the Tutorials section here. Once you are beyond the stage of simply closing your eyes or hurriedly looking away at the sight of a chunk of Perl script I strongly recommend that you look at the questions and answers in the Seekers of Perl Wisdom section here. That will give you a wide exposure to applications of Perl from the very mundane to the highly esoteric - just pick the questions you feel somewhat comfortable with or that seem applicable to your area of interest and then squeeze all the juice out that you can get.

    Using Seekers of Perl Wisdom as a learning resource is a really good way of finding out about a lot of tricks, traps and generally cool stuff as well as getting a good feel for how to write practical Perl well.

    True laziness is hard work
Re: seeking direction to start with perl
by Your Mother (Archbishop) on Feb 04, 2010 at 05:04 UTC

    Perl for Sysadmins, ISBN 9781565926097 and Minimal Perl: For UNIX and Linux People, ISBN 1932394508 are worth picking up. Quite a few of the online tutorials give some awful advice which may, sometimes, get the job done but will cripple your growth and enjoyment of Perl. Ask questions here often and you'll get, usually, good advice from all kinds of perspectives and areas of expertise.

Re: seeking direction to start with perl
by biohisham (Priest) on Feb 04, 2010 at 06:24 UTC
    It may be worthwhile for you to check the Reviews section of the Monastery. You can see which books are recommended and weigh for yourself how a certain book can be of potential benefit.

    once you have learned a basic deal of Perl - no matter which book you read from - the Seekers of Perl Wisdom is such a great medium of interaction and learning since you are offered practical solutions from different perspectives for a coding problem that you faced while learning/working, this can allow you to explore areas where you can develop your coding style and give you better ideas. I have learnt a lot only by following the SOPW and I can never cease to learn new things every passing day from this section...

    I'd emphasize that you organize this learning experience and make provision for reviewing your progress every other while in order to solidify the techniques you learn and facilitate picking up new ones and thus building on some solid base.

    So welcome and have a nice Perl journey..

    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.
Re: seeking direction to start with perl
by desemondo (Hermit) on Feb 04, 2010 at 04:22 UTC
    Perl Best Practices is a pretty good place to start - although it does have a little assumed knowledge...

    Ultimately though, I'd just pick one of the books (eg the Camel book) and dive in and start writing Perl.

    I found learning Perl in a "Read, Write, Read, Write" style quite good in that I tried to apply what I'd just read to the code I wrote. Also reading a book cover to cover, then going back through it a 2nd time - helped fill in a few gaps on some areas I didn't get the first time through

    Hope this helps.

    In my opinion, Perl is simply another tool in the toolbox, which may or may not replace your Shell scripts - depending on what you're trying to do. In the 'sysadmin' role, choosing the right tool for the job is just as important as knowing the tools themselves... Building code that is robust, efficient and maintainable is a delicate balance when solving a non-trivial task.

      In my opinion, Perl is simply another tool in the toolbox, which may or may not replace your Shell scripts
      I advocate writing all non-trivial new scripts in Perl, not shell. As for why, see Unix shell versus Perl.

      Re learning Perl in general, a good place to start is

        I advocate writing all non-trivial new scripts in Perl, not shell.
        Absolutely, I totally agree.

        The point I was trying to make was that shell scripts are ideal for simple stuff. And that it doesn't usually make sense to use Perl for those tasks... Unless those scripts are beyond two or three lines, or the shell doesn't provide enough power or control.

        In otherwords, if the shell already provides what you need, there isn't much (or any) benefit in rolling your own, whether it be in Perl, VB, php, or any other scripting language...
Re: seeking direction to start with perl
by BrowserUk (Pope) on Feb 04, 2010 at 08:31 UTC

    Learning a new langauge by using it for new (always urgent) projects doesn't often work.

    You find yourself sitting there frustrated to hell trying to work out how to do something trivial, that you know you could do in your old langauge almost without thinking, and you usually revert because of the time pressure.

    And if you try coding all those nice-to-have-but-you've-never-found-the-time-for projects that have been kicking around, you'll never finish them because there's no pressure to do so.

    Make a list of the old language programs that get most use or require most maintenance and sort them by loc ascending in a scratch/private directory. Then try setting aside 30 minutes a day or whatever suits your schedule and go through them one-by-one in order and do your best job of converting them to Perl. Don't sweat the detail of testing and robustness on your first pass. None is ever going to use them for real. The idea is to force yourself to just work out a way to tackle those familar tasks in the new language. As you go through them, you'll find better ways of doing things you've already done earlier. Maybe go back and update those earlier attempts..

    One day soon you'll need to write something, and the Perl solution will pop into your head before the old language solution does. At that point, if the new script is anything other than a throw-away, you'll probably still need to write it in the old language because of testing/robustness. But then is the time to set up a more formal attempt to do the same thing in Perl in parallel, and perhaps post your attempts here for critical review.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I found the Perl Cookbook a great way to learn as it suits my, admittedly lazy, approach;)
      The examples there and indeed the Seekers of Perl Wisdom here are great for exposing you to correct Perl idioms.
      Like yourself I came to Perl from a Unix admin perspective with a knowledge of scripting and a little C. The difficulty you will encounter is that such knowledge predisposes one to write inefficient Perl ignoring the idioms of the language and so looking over better code will improve your own.

      print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: seeking direction to start with perl
by DrHyde (Prior) on Feb 04, 2010 at 11:13 UTC

    When I started with perl, I had a copy of the Llama book (Learning Perl - it was very good back then, including material that isn't in the docs that come with perl, I presume the current edition is just as good) and quickly got a copy of the Camel book (Programming Perl - maybe not so useful these days now that everyone has enough screen space to edit their code in one window while using perldoc -f in another).

    But most of my learning wasn't from those books. It was from finding and downloading other peoples' code that did almost what I wanted but not quite. To get exactly what I wanted, I had to read the code, understand how it worked, and fix it. So I read lots of code, gained a good understanding of it, and wrote a little bit. This was done at work, with deadlines, and it's purely by luck that I fell into using perl instead of any other language: I simply found perl stuff that almost worked before I found anything else that almost worked :-)

    I don't guarantee that that will work for you, of course, but it's an approach that might be worth trying.

Re: seeking direction to start with perl
by planetscape (Chancellor) on Feb 04, 2010 at 14:17 UTC

    Welcome to the Monastery! For exercises or self-imposed homework, you may wish to peruse Re: Real Life Perl Exercises. Good luck!


Re: seeking direction to start with perl
by cdarke (Prior) on Feb 04, 2010 at 10:26 UTC
    BTW: any command to convert shell script to perl ?

    See UNIX 'command' equivalents in Perl

    See also App::sh2p, except you probably do not want to. It is not finished (probably never will be) and the best you can expect is to take some of the tedium out of converting a large script - it will not necessarily generate runningcode.

    Most shell scripts are so poorly written that a rewrite in almost any language will help - not because the shell is bad, but most shell programmers are terrible. This will not apply to your scripts, of course.
Re: seeking direction to start with perl
by eyepopslikeamosquito (Bishop) on Feb 04, 2010 at 07:29 UTC

    BTW: any command to convert shell script to perl ?
    No. Though there is merlyn's famous sh2perl joke.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://821312]
Approved by GrandFather
Front-paged by biohisham
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2021-01-26 10:02 GMT
Find Nodes?
    Voting Booth?