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

Perl for admin tasks

by gmax (Abbot)
on Feb 09, 2002 at 09:22 UTC ( #144335=perlmeditation: print w/replies, xml ) Need Help??

The latests Freshmeat's editorial is an interesting discussion about building software. Among other pieces of sound advice, there is one in particular that I like:
I automate virtually everything. In fact, an extremely complex Perl script is writing this article for me. I'm really asleep...
Which brings me to Perl. I began using it in 1996 and am still learning some neat tricks. This is really the Magic Belt. Using Perl, I have automated tasks that at first seemed completely unapproachable.

Reading these lines, and similar examples later in the same article, reminded me that I am basically using Perl for its original purpose, i.e. as a tool for administrative tasks, especially automating the boring (but most important!) ones .
As a database administrator, I appreciate the virtues of Perl. Whenever I realize that I am typing the same task twice, my mind starts transforming that task into a Perl script.

As a database designer, I often need to analyze existing chunks of horrible data in order to mutate them into a reasonably businesslike database. Really an enjoyable job, if you like the idea of extracting usable data from a pack of junk in a monster flat file. :) In these chores, Perl is absolutely invaluable1. Before embracing Perl, I used to meet these needs with C (Don't worry. I am cured now, and the doctor said it wasn't infectious.) Although my tools of the trade were fit for the purpose, it wasn't that easy to adequate a program to solve problems that were slightly different from the original ones.
With Perl, I can often change the whole task by replacing or modifying a regular expression in my code while in C I was sometimes forced to more committing an unpleasant structural changes.

Moreover, although I don't use Perl to produce full (web based) clients, I have perl scripts working in the shadow of traditional client-server applications, doing integrity checks, cleaning data, building statistics summaries and so on.

There's More Than One Way To Do It, and Perl has almost all of them.

update Corrected a typo (thanks dws). s/unvaluable/invaluable/. It could have been interpreted as if I despise Perl! :)

 _  _ _  _  
(_|| | |(_|><
1 <free ad>If you don't trust my word for it, there is a book that might impress you better.</free ad>

Replies are listed 'Best First'.
Re: Perl for admin tasks
by ralphie (Friar) on Feb 09, 2002 at 18:02 UTC
    one of the best parts is the look on people's faces when you make something pop up from nowhere. one of my recent endeavors was to set up to script to parse a very complex log from an hp lab instrument. i connect to it via a samba share, parse it, and insert the results into a postgresql database on a small database server. i set up a series of cgi scripts so they could query the database on various parameters as the users' way to getting to the results. not a big deal, once you put together the pieces, but it's real neat to go from a situation in which they go from being virtually unable to get to results from past runs to one in which they can do it without ever seeing the data going in.

    who said this stuff wasn't magic.

(shockme) Re: Perl for admin tasks
by shockme (Chaplain) on Feb 10, 2002 at 02:32 UTC
    I've been on the job for just over a month now, and I already have people stopping me and requesting perl scripts. First, the-boss-of-my-boss requested a script to parse a fairly complex log generated by our inside router. Later, I discovered that one of our security guys was manually digging through email every month to locate which ones contained viri in order to produce an Excel spreadsheet showing how many viri were received and how many were sent. In about 15 minutes, I had a script which would parse the monthly logs and, in about 3 minutes, produce what took him days to do. His response was "Man, I have got to learn Perl." My boss' response was "Where were you two years ago when we implemented all of this?"

    I didn't answer. He doesn't really want to know where I was two years ago . . .

    If things get any worse, I'll have to ask you to stop helping me.

Re: Perl for admin tasks
by belg4mit (Prior) on Feb 09, 2002 at 17:52 UTC
    I don't know what the big deal about adminstration capabilities is, automation pffshhh is that some kind of cartoon made with cars?

    Seriously though, while I guess I do technically use it to automate some things more often than not I'm either using at as the Pathologically Eclectic Rubbish Lister or as a "shell script" on steroids.

    Of course it makes a lot more sense for [gs]et.* and crypt to exist in the context of automation and adminstration ;-).

    perl -pe "s/\b;([st])/'\1/mg"

More Uses For Perl - Re: Perl for admin tasks
by metadoktor (Hermit) on Feb 09, 2002 at 09:59 UTC
    use God; God->let_there_be_light();


    "The doktor is in."

      package God; $_42 = Universe->new(); $_42->fiatLux();

      perl -pe "s/\b;([st])/'\1/mg"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://144335]
Approved by root
[stevieb]: Joan Jett, Hendrix, Neil Young, Dave Keuning (The Killers)... I have my mind elsewhere so I'm limited in my capacity to think about this righ tnow ;)
[erix]: another blues with Big Red :)
[stonecolddevin]: I will say John Mayer is an excellent guitarist, I don't like his music but he's pretty damn good
[erix]: scd: maybe you like John Mayall better :)
[erix]: (mayall = british blues)
[planetscape]: sleep well, Corion
[stonecolddevin]: erix seems pretty good, i listened to "So Many Roads" and it was nice. Not everyone's cup of tea but this guy can absolutely shred, he and the guy from Mastodon are definitely up there: https://www. v=VzhMkSN9dQc

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-06-22 21:42 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (531 votes). Check out past polls.