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

I have a question, obviously about perl. I am a systems administrator for a microsoft network. At that I am very good. It is my opinion that you can't be a great SA and a great coder. I know several of both and they all feel the same way, many of you may disagree, but I say that to illustrate my point.

I am a very good SA and I want to become a good coder. I sincerely feel that learning perl is "THE!" way to go. I have downloaded "Learn Perl in 21 Days" it covers perl 5. I have begun reading it and practicing the code in there and using a piece of software called Perl Scriping Tool from for perl 5 but none of the code I type character for character and space for space seem to work. I have borrowed some code from this site and tried to run it in that tool and it didn't work. I think it is the tool actually but I don't know.

Where should I try to learn perl @ on a linux platform or windows and is is it truly the same on both platforms? Will the exact same code run on both platforms the same way. If anyone would care to help out a mentally crippled SA I am trying to figure out what I have to do to get the orphand home directory script on this site to run?????? HELP????? and thanks in advance.

PS I am ignorant of the entire science of programming so feel free to make fun of me, just help me out......k? Email me @

Edited by footpad, ~ Fri Sep 20 03:14:09 2002 (UTC) : Retitled, per Consideration (and added HTML formatting)

Replies are listed 'Best First'.
Re: Beginning Perl for system admins
by VSarkiss (Monsignor) on Sep 19, 2002 at 21:25 UTC

    First, get a better programming resource. Two very good books to learn Perl are Learning Perl and Programming Perl, both by O'Reilly. The latter is oriented towards those who already have a programming background, so it may not be a good one for you. I don't know the book you mention, but the "in 21 days" part makes me suspicious whether it's any good. Look in the Reviews section here in the monastery for some good reviews of existing Perl books.

    Second, this "Perl scripting tool" doesn't sound like a full Perl implementation. For a Windows platform, I use ActiveState's Perl implementation. There are others, including IndigoPerl from IndigoStar, but I've never used it, so I can't vouch for it.

    Some of your other questions:

    • Yes, most Perl programs will run on any platform, but some functions don't work the same everywhere. ActiveState's documentation has a list of "this works, this doesn't" on Win32.
    • The monastery is an excellent resource (IMHO ;-) for those learning Perl. Whether a book, the docs themselves, a course, or an online tutorial will work better depends entirely on you. There are Perl books specifically for system admins, but I think those are more oriented towards Unix/Linux admins, like Perl for system adminstration, which is multi-platform. You can find some very good resources on Perl for Win32 admin at
    • I have no idea what the orphaned home directory script is, so I can't say anything there.

    Anyways, Welcome to the monastery! Make yourself at home. Read the FAQs and don't be embarassed to ask questions. (Oh yeah, read the Writeup Formatting Tips. ;-)

    Added links to books.

      I'd add a link and a comment to those great links: Learning Perl for Win32 seems to be something you are looking for, too.

      Moreover, I completely agree with VSarkiss about Perl for System Administration. I bought the book an year ago or so, and thats absolutely a must-have for "coder-sysadmins", as you call them. Each and every problem is treated on the three most popular macroplatforms: UNIX, Windows and MacOS. It was worth the money I paid for it!


      PS: I forgot: I am a coder sysadmin :-)

      # Another Perl edition of a song:
      # The End, by The Beatles
      END {
        $you->take($love) eq $you->make($love) ;

      If the book is Teach Yourself Perl in 21 Days by Laura Lemay, it's a perfectly good way to learn perl. The 21 days part is decieving: you could only devour the book and do all its exercises in 21 days if you did nothing else except sleep and eat. Even then, you wouldn't get enough practice with all the things you learned.

      I got through the first few chapters in a few weeks, and then referred back to the book when I wanted a tutorial on, say, regexes, or the debugger. That, the manpages, and Perlmonks were all I needed to get a pretty solid foundation of the language.

      If it is this book, then it has a fairly extensive chapter and apendicies about how to obtain and set up Perl on Unix, Windows, and MacOS. The only thing that makes me suspicious is that jjohnson says "I have downloaded \"Learn Perl in 21 Days\"". This either means that I'm thinking of the wrong book, or that jjohnson just downloaded the code listings from the book's site and didn't read the book. That's usually not a good way to learn Perl.

      Tell us when you get it working, jjohnson.

      How do I love -d? Let me count the ways...

        He's quite possibly talking about the Lemay book, as I've seen it available as (scanned+ocred+formatted) on irc several times.

        I bought it, and it is good, though I didn't spend more than the allotted time (as perl is my 3rd/4th language, I could jump the first few days quite quickly) It's not a replacement for the camel (which I have acquired later on), as it does not delve into OO or the other more advanced stuff very much. It's well-written, though, and clearly understandable.

        Anyway, I meant to say, don't download the book, buy it, it's worth the money.

      but the "in 21 days" part makes me suspicious whether it's any good
      If it is the book I think it is, from SAMS, you are absolutely right in your suspicions. That book is maybe my worst buy ever.

      As a book to get an overview of the language as such it is maybe ok, as it covers most of the basics, but as I feel, in a semi-random order and skipping lots of important parts. The really bad part is however, that once you've finished with it, it is of no use any more, as it virtually impossible to use it as a reference - because it lacks an understandable structure and has no good index.

      This is pretty harsh claims, so I wish I could back it up with examples, but I gave that book away to someone at work.

      I bought it as my first perl book, and in all honesty, I learnt more from Perl 5 pocket reference. Then I bought the Camel and all was sunshine again.

      I don't know if this should be a disclaimer or another argument against the book, but before Perl I had been programming other languages and worked as a developer for some time. That may affect what works or not I guess.

      This is only how I experienced it, I am sure the book has been very succesful in helping others. For me, I'll never buy one of those "Teach yourself in X Something" again, and never anything from SAMS.

      You have moved into a dark place.
      It is pitch black. You are likely to be eaten by a grue.
        You had me there until the last paragraph.

        Some SAMS books are bad. In fact, prior to 1999 I'd say *most* of SAMS books were bad. A lot of it has to do with the editorial process of which I've got firshand knowledge. So trust me there. Things have improved though.

        The same could be said of any publisher. ORA and Manning both have some real stinkers on the shelf right now at my local bookstore.

        My own "Teach Yourself X in Y" book has gotten very *good* reviews from both a readability and technical standpoint. It doesn't teach any bad habits that I've ever been told of, was widely tech reviewed in an open process by dozens in the Perl Community, has a friendly style to newbies, and as a result sells like gangbusters everywhere.

        I'd send you one to review, except your attitude's a little hostile and negative right now and I don't know if it'd do any good.


        On a related note, I've always held there's two kinds of tech books: ones you learn a subject with, and ones you use for reference. There are very few books that fit both categories well. The Llama is a *terrible* reference book, it's organized all wrong for that and it's not supposed to be a reference. But it's pretty good to learn from! The Camel is an *awful* introductory text to Perl. It far too steep and organized around the parts of the language and not tasks to be done with it. It's a great reference and map to the language.

        Of course, by "learn a subject" I mean starting fairly low on the curve. If you're already an adept C, Lisp, Java, Shell, Pascal, Smalltalk, and C++ programmer and you're learning Perl for the first time you'd probably be happy with a reference and a few examples. If your programming experience is limited to BASIC and some Pascal you took in college then you're a different creature entirely.

        Are there any books that do well at both? Possibly. K&R does a nice job, before it got too footnote-heavy in the second edition. But C's a microscopic subject compared to Perl. Steven's first edition of the Network Programming book got it right and does both well. His Unix book though was kind of steep for learning a new system, but great if you already new a bit of this and a little of that.

        I borrow a learning book, spend some time with it, and then permanently loan it out again. I then go out and buy a reference book and keep it forever.

Re: Beginning Perl for system admins
by bart (Canon) on Sep 19, 2002 at 21:52 UTC
    I have begun reading it and practicing the code in there and using a piece of software called Perl Scriping Tool from for perl 5 but none of the code I type character for character and space for space seem to work.
    Hmm... do you even have Perl installed? Start with getting ActivePerl from Activestate. Next, get a decent editor. (I have the feeling this is what you actually got from As a sysadmin you probably already have a preference — personally I like GTE from GWDsoft. I hope you can set it so you can run an "external tool", and capture the output (preferably both STDOUT and STDERR) to an output window? Set it up so that it can use as a tool perl to run your script.

    Next step: try to run the simplest of scripts, for example the classical "Hello world" program:

    #! perl -w print "Hello, world!\n";
    You'd have to try extremely hard to screw this up. Just put it in a new text window and save the file as a text file with a ".pl" extenson. If you try to run it with perl as the tool, and you get a friendly message in your capture window, then you're on your way.

    The docs with ActivePerl come both as HTML and as POD, so you can read and print them with your browser, or you can use perldoc, a perl script wrapped in a .bat file, which resides next to the perl executable(s), as a tool to look things up for you, and display as plain text in an output capture window in a your editor.

    You can install new modules with the PPM utility, another perl script in a .bat file, from a DOS prompt.

    Good luck!

Re: Beginning Perl for system admins
by knowmad (Monk) on Sep 19, 2002 at 21:22 UTC

    If written to be cross-platform, Perl scripts are easily portable. I develop under WinNT and post to Linux and FreeBSD servers regularly. There are a few things to keep in mind when uploading (ASC uploads) but otherwise no problems with the different OSs.

    I'd suggest trying to use perl from the command-line just to be sure you have it setup properly. Can you get a response from 'perl -V'? Try to run a perl script via 'perl' (substitute the name of your script!). Once you've confirmed that perl is installed, then begin to debug whatever tool you are using.

    Good luck, William

Re: Beginning Perl for system admins
by grantm (Parson) on Sep 20, 2002 at 09:22 UTC
    It is my opinion that you can't be a great SA and a great coder.

    It's hard to image a better training ground than being an SA (but then that's my background so I would say that). One of the things that distinguishes a great coder from a good coder is attention to detail and that's typically something that good SysAdmins have in bucket loads.

    A SysAdmin also tends to recognise fairly quickly when something will be supportable in the long run - a programmer who has never done support might not even care. SysAdmins are usually fairly close to users and have a pretty good feel for what things they find frustrating or could use help with. This is the perfect opportunity to spot a little project to sink your teeth into and implement in Perl.

    For example, say someone in your organisation regularly emails (or FTPs) some files to a business partner. You could put a script together using Mail::Mailer or Net::FTP and run it from the system scheduler. If the person saves 10 minutes a day that adds up to one whole week over a year - you'll be a hero!

    As another example, are there any log files you check on a daily basis? What do you look for? Write a Perl script to look for the same things, schedule it to run daily and each morning when you arrive at work there'll be an email in your In Tray telling you (from the subject line) whether everything is OK or not. If you save yourself 10 minutes a day, you can spend it on Perl Monks.

    And I wouldn't get too hung up on 'the science of programming' - for your needs, a little common sense is all you'll need. After you've got a few projects under your belt (and made a few mistakes like we all do) you may find that you're interested enough to read up on some of the theory and you'll have some real-world experience to relate it back to. Good Luck.

      Best advise I can give you. If you want to learn from the best Perl programmers then you should spend alot of time on Perl Monks. These people are very helpful!
Re: Beginning Perl for system admins
by AcidHawk (Vicar) on Sep 20, 2002 at 05:57 UTC

    I come from the same place as where you are at now.

    I was a Windows Sys Admin for a while and started to "see if I could do it" using batch files. (Do it was all sorts of different mundane tasks.)

    Some-one told me to look at Perl. - WOW.. I haven't looked back since. In fact I have put together a Auto Call Logging system that does correlation etc from a management system (TNG) to the Helpdesk system ARS. Writing in Perl has taken over everything I do at work..

    My first thought is can I do it in Perl. Sometimes I am critisized for this as there are often quicker point and click methods for doing the same thing... But Perl is fast if not already becomming a passion for me.

    I found several really helpful resources on the web for assistance in learning perl.

    1. You have found this one already. PerlMonks

    2. Roberts Perl Tutoiral

    3. For Win32 Resources and he has 2 great books out Dave Roth

    These have helped me more than I can repay. Hope they help you also.
    Of all the things I've lost in my life, its my mind I miss the most.
      Spot on, Bro. I agree with what you have said word for word.

      Also, I found the Cook-book from the O'Reilly series is a great source for quick recipes.
Re: Beginning Perl for system admins
by rinceWind (Monsignor) on Sep 20, 2002 at 18:24 UTC
    It is my opinion that you can't be a great SA and a great coder.
    Why not? Is there some great piece of IT folklore out there that the skills for one preclude the other? In my opinion, this is like the other great myth of the corporate world - that you can't be good at IT and a good manager. I have encountered several exceptions to this, and I recommend looking for and supporting any boss who is skilled in both areas. You need a manager like this to help you fight any battles over infrastructure.

    Coming back to sysadmins. I have been a Unix and VMS sysadmin, I have also been a developer, support person, business analyst and tester. Perhaps it is because I have been a sysadmin that I can appreciate the role, and I tend to make my sysadmin colleagues' lives easier for them (I am currently assigned as a developer and application support person).

    Having experience as a sysadmin gives you insight into a number of programming and design issues, for example:

    • Security
    • System performance
    • Portability
    In my opinion, someone who has not been on the sharp end of these issues as a sysadmin will fail to grasp the consequences of what they are programming, and will write code that fails one or more of these criteria.

    My $0.02


      ... because both jobs are damn hard!

      I think the "programmers can't be sysads" folklore comes from two beliefs: (1) sysads and programmers were adversaries back in the days when programmers fed stacks of cards to the Machine God behind the glass window, and (2) programmers are theorists with no concern for the real world, while sysads Get Jobs Done.

      In truth, the same basic skills apply to both jobs. Sysads need to handle pressure a bit better. Programmers need to handle abstraction a bit better. Sysads tend to use lousy tools too, so secondary skills like record keeping are more important for sysads.

      The biggest problem both jobs have is the folklore that people can learn them by taking some ad hoc training. Many people without formal training have become good sysads and programmers. The big lie is that people don't need structured, progressive, disciplined training. They do. If someone doesn't have the self discipline to do that independently, he or she really needs the support of a university. (or monastery ;)

        Thank you blssu for enlightening me as to where the dichotomy between sysadmins and programmers comes from. Also thank you for boosting my confidence convincing me that people with my skills are in short supply.

        Although I have a computer science degree, and other training as a programmer, I have always had a "let's peep under the hood" approach to what I am doing. I believe there is a huge overlap, including "Technical Support Consultant" and "Systems Programmer" - both roles I have done (technical support is what I am doing at present).

        I see the solution, not in terms of external discipline (University or PM), but in terms of changing the attitude of colleagues in work environments. I believe it is really a question of leadership.

        Being a self confessed jack of all trades, I see no reason why people with a particular job description should always stick together, forcing work into vertical silos. The much better structure is smaller - cross discipline - teams, where everyone is working towards the same goals. These are: solving the client's problems, delivering software solutions and making money for your employer's business.

Re: Beginning Perl for system admins. (Free your mind! This is what Perl do for codes.)
by gmpassos (Priest) on Sep 21, 2002 at 01:07 UTC
    "It is my opinion that you can't be a great SA and a great coder"
    Hummm! Are you nut?!
    I think that you need to meet more peoples!

    Man, be a SA or a Coder is just a name for doing something. The human mind is free for doing every thing, since that you don't put any limit for her! Tell this is the same to tell that you can't swim because you can walk!

    About your initiative to learn Perl to be a Coder, congratulations, you got the best way. If you learn Perl, in the future you will be able to learn any other language. Do you know why? Because Perl don't put limits in the way that your mind can think (can be creative). With Perl you can do the same "think" in many ways, you just use what is the best for you. You can do with a lower knowledge or a big, good codes or bad codes, but in any way, will be easy to do what you dream!

    About how to learn! Well, only YOU can know that!!! Each peoples is VERY different from other. You know why? Because everyone think different, has a different mind, is a different universe, and the way that someone use can not be the best for you!

    Learn a programming language is the same to learn a speaking language! The best way is not make 10 years of lessons with a teacher, the best way is go to the country or start to speak with someone that know that langue! Because when you speak you use what you learn, you have a reason to know what you learn! If you want to learn Perl, find something that it can do for you and make the codes! For example, you can use it to manage a server. If you start reading a book, well, can be good, but the book comes with a lot of things that you don't need to know now, because you don't have the bases to use them. If you try to learn some lessons, or tips, in one year you will don't remember this lessons, because you don't use them! The best thing is learn step by step, following your needs. And don't forget, the best book is called "Internet"!

    To learn Perl, or any other thing, you just need:
    - To want, need.
    - To use, practise.
    - Have where to learn, where to get information. But don't worry, they had inveted Internet! :-P

    I can give you some tips. Always know what is what, and why! You need to know what is any dot, slash, quote, any thing that you use! If you start to use what you don't understande, first you lose the chance to learn, and will be hard to past to another level! And probably will be hard to work well!

    This last link I think that is the best to start! This is a simple, small and good doc that just explain the commands, the rest you already have, a brain to play with the "LEGO". I only used this to start to use Perl, 8 years ago, and it still are in the internet in a lot of places!

    You can get some editor too! You can find betters, but to start DzSoft Perl Editor will be good ( And you will need the interpreter for your OS. For Win32 go to and get ActivePerl (install it in the default: c:\perl). Perl was born on UNIX family, and works better on it (Linux). But now the Perl community made a hard and good work to port it "fully" to other OS, and it work very well on "any", since Perl is Open Source and have a architecture to be portable.

    Graciliano M. P.
    "The creativity is the expression of the liberty".
    (Now you know why I always sing with that!)

Re: Beginning Perl for system admins
by hardburn (Abbot) on Sep 20, 2002 at 13:45 UTC

    Use Cygwin. It gives you a *nix-like system over Win32. You can find it on Perl is included in the Cygwin packages, though it is a little buggy at times. Most of the problems I've had are with weird CPAN modules (like Date::Discordian).

      I disagree. Cygwin is nice to get a generally Unix like environment under Windows and I use it every day, but its Perl distribution lags behind Activestate's and is far harder to get working and harder to integrate with the Win32 class of modules.

      Helgi Briem

        I agree. For SA work on Windows, go with Activestate. I think Cygwin is handy if you need to deploy to Unix. The really valuable modules you'd use for SA work on Windows (Registry, OLE and the like) are going to be quite challenging to get working under Cygwin, but they are tested and readily available under Activestate.

      Good you brought that up. For me, Cygwin is one of a very few reliefs that keeps me from throwing cakes at a guy named Bill. Working on Unix (thank God (for making Linus ;)) most of the time, it saved me from a severe adrenalin rush more than once when I typed ls -la in a DOS box... ;)

      When it comes to Perl under Win32, I use ActivePerl, which integrates seamlessly into CygWin and vice versa. Actually I'm impressed by how well this integrates. I use LyX under Cygwin, running on a Win32 X Server, which calles Win32 MikTeX to produce output. Cool stuff. The world could be such a fine place... ;)

      But 'nuff of that. Even if you're a M$ apostle Cygwin will make sense, and if it's only that you have a ls, ps, etc. at hand, just in case someone want's to backtick to them. And many examples in the Perl docs or books or on PerlMonks will have some reference to those tools. Besides that Perl set aside for the moment, you'll get rsync and wget and lot's of other tools that might be quite helpful especially for a sysadmin.

      So long,

Re: Beginning Perl for system admins
by helgi (Hermit) on Sep 20, 2002 at 15:28 UTC
    jjohnsson wrote: I have a question, obviously about perl.

    Your question is, but that is by no means obvious for most Perl questions.

    In fact I would hazard a guess that the vast majority of "Perl questions" are not about Perl at all, but about a variety of other subjects of only peripheral relevance, for example:

    web server configuration
    shell scripting
    line endings in text files on different operating systems
    file permissions

    BTW, no programming language works "exactly" the same under different operating systems, but Perl comes closer than most.

    Helgi Briem

      IMO, Perl is great as a beginning, and a repeat language. I started out programming in Perl (and for what it's worth I am still very much a beginner) and I have never regretted that choice. I have found my computer science classes to be much easier having learned what I did in Perl, as it was a great basis of introduction into the way of thinking a programmer should have. I would recommend merlyn's book Learning Perl, as I have read it at least twice, and it was a great starter source. After you read the Llama, I read the Camel (Programming Perl) and frequently use it as a reference whenever I need to solve a problem (I can't tell you how much that index of commands helps me).

      I know absolutely nothing about being a SA, but I'm sure you can take up Perl as a spare time kind of habit, and become a good SA and coder over time.

      Good luck and -w, use strict;
      work it harder make it better do it faster makes us stronger more than ever hour after our work is never over.
Re: Beginning Perl for system admins
by mattr (Curate) on Sep 22, 2002 at 05:10 UTC
    Ditto. Congratulations for wanting to learn Perl, it is good for all Perl people to have more Perl people in general. Especially if you become a good coder and contribute something to CPAN that is useful, which is likely if you are an active sysadmin.

    That said, I do find it a bit amusing that you ask for help while stressing how fantastic a sysadmin you are when maybe a third of the people here are too. And thanks for your email, but you won't probably get any emailed replies..

    You can be a sysadmin and code. Though maybe you could be a better sysadmin by *reading* more. If I was to say one thing is most important about being a good X in computers, especially Perl, is you have to read and try to figure it out. Also I think while not absolutely essential, linux is a good place to do the experimentation because it has less barriers to doing useful things, and more free tools, plus it will help get you to pry into things and make sure they work the way they are supposed to, instead of getting too cozy with standing an armlength away from what's going on as usually in Windows. However it will take a good part of your time to learn linux too. Perl and Linux both reward effort.

    So I think you are starting out with a need for some philosophy. Not to be personal about it, but I would think twice before hiring a sysadmin who could not install perl and run a few simple programs with it, and came running to the discussion boards right away before doing some reading of the installation guides, tutorials, and FAQs. Also you apparently did not format your post with HTML tags as we all do.

    I think the same kind of proactive (shall we say determined or obsessed?) attitude, and a cheap Internet connection, are the best tools you will have to learning perl. There are resources about systems administration with Perl, but I would start just getting into some basics first.,, are good places to look at. PM is also good, for example variations of your question have been asked umpteen times.. though I think people like answering each time here. My recommendation is to start with the perlfaqs and some overviews, and take a look at related posts here to see how people think about solving problems in Perl. This will be more rewarding in the long run than just memorizing cae-by-case formulas from those Perl in umpteen hours books. Oh yeah, Learning Perl is supposed to be pretty good too.

    Keep at it!


    P.S. If on Windows, upload via FTP as Type ASCII, since carriage returns may cause your script not to execute. As mentioned in the faqs.

Re: Beginning Perl for system admins
by Popcorn Dave (Abbot) on Sep 21, 2002 at 04:45 UTC

    One book that I have found indespensiblle for Perl is the Perl Black Book. It's got about 25 chapters ( give or take ) and practically each page covers one small bit of Perl. It's written in the style of "the novice programmer says 'How can I do this?'" so it's been a great reference for me.

    The O'Reilly books are also high on my list, but I've been programming for 20 some odd years now. They're probably not the best to start with if you don't have any coding background. That said, the teacher I took Perl from was thinking about changing from the O'Reilly to (what I assume) was the WROX (publisher) series. Currently I'm using theirs for JavaScript and it is definitely geared towards the beginner, so that may be the one for you.

    Good luck and welcome to the Monestary.

    There is no emoticon for what I'm feeling now.

Re: Beginning Perl for system admins
by ellem (Hermit) on Sep 22, 2002 at 02:51 UTC
    I am going to say some things that you will not like. I am sorry.

    I must question your contention that you are a very good sys admin. First you seem to have little grasp on how a computer works. You downloaded some code and expected it to work. This is ridiculous. My guess is you are in charge of some computers possibly a server. You are probably better than most where you work and some may call you a Sys Admin. None of this makes you stupid, or a bad person.

    Now you endevor to learn Perl but have already decided that Sys Admins and "coders" can not be the same person. This is untrue, silly and the people reinforcing this notion around you are sorely mistaken. They are neither stupid, nor bad people.

    OK, now about where to Learn Perl.
    Download Perl from ActiveState
    Here at Perl Monks
    Learning Perl on Win32 Systems
    WIN32 Perl Scripting for Systems Administrators

    Now that should take a lot longer than 21 days but you will become a great Sys Admin and proabably a damn fine coder.

    As you learn to code you will come to respect knowledge and hopefully you will not download books! (If I misread your post I apologize but it reads as if you've found a scanned version of the book somewhere.)

    No off with you! Learn.
    There's more than one way to do it, but only some of them actually work.
Re: Beginning Perl for system admins
by virtualsue (Vicar) on Sep 22, 2002 at 11:52 UTC