Slashdot Mirror


Wicked Cool Perl Scripts

Michael J. Ross writes "Of all the popular programming languages now in use, Perl is perhaps the best suited for writing utilities — for several reasons, such as its text-processing capabilities, ease of addressing system resources, and minimal language overhead for input, output, list processing. It was designed to blend the rapid solution development of shell scripting with the powerful control constructs of third-generation languages. Consequently, Perl quickly became a favorite language for developing programs ranging from system administration utilities to CGI scripts that power Web sites. In fact, Perl has been called the glue that holds the Internet together. The tremendous flexibility and power of Perl is seen in Steve Oualline's book Wicked Cool Perl Scripts: Useful Perl Scripts That Solve Difficult Problems." Read the rest of Michael's review Wicked Cool Perl Scripts author Steve Oualline pages 336 publisher No Starch Press rating 8 reviewer Michael J. Ross ISBN 1593270623 summary 47 useful Perl scripts for Web site management or CGI, Linux or Unix system administration, managing pictures, etc.

Published by the cleverly named No Starch Press, Wicked Cool Perl Scripts comprises 336 pages, spanning 11 chapters, with a brief introduction, as well as an index. The book appeared in February 2006, and was published under the ISBN of 1593270623. No Starch Press maintains a Web page for the book, where readers can find a sample chapter (the third one, covering CGI debugging), in PDF format. There is a link for downloading all of the source code.

The book presents 47 scripts, grouped into 11 categories: general-purpose utilities, Web site management, CGI debugging, CGI programs, Internet data mining, Unix system administration, picture utilities, games and learning tools, development tools, mapping, and regular expression graphing. The scripts perform such functions as finding duplicate files on your PC, converting currencies, processing error logs, generating jokes randomly, getting stock quotes, and managing photos and other images. Some of the scripts play games, while others would be invaluable to any Linux or Unix system administrator. For readers with their own Web sites, the book offers scripts for verifying links, locating orphan files, detecting hackers, and locking them out. In addition, there is a script for counting the number of visitors to your site, and even one for presenting a guest book. Software developers will find the material valuable, as there are Perl scripts for generating code, locating dead code, and handling regular expressions — parsing and graphing them.

The scripts themselves are fairly wide ranging in complexity and size, with a few fitting on a single page of the book, while others require more than ten pages. Fortunately, the scripts generally contain enough comments to be clear in how they work to any programmer comfortable with the language. Nonetheless, the author explains how to run each script, what sort of results the reader should see, how the script works, and what modifications one might want to make to it ("hacking the script"). In addition, every one of the scripts contains a POD (Plain Old Documentation) section, though only in the downloadable version — not the version seen in the book, to save space.

It is doubtful that any beginning Perl programmer might mistake this book for a Perl primer or reference. The title alone makes clear that the focus is on the offered scripts themselves, and their ability to help the reader solve common problems. On the other hand, Perl programmers of any level of fluency with the language would benefit from reading through the scripts, as well as the author's explanation of how they address and solve each problem. I myself have been programming in Perl for ages, and yet I spotted CPAN modules that I can use in my own Perl scripts in the future.

The value of the scripts themselves to each individual reader, naturally depends upon what sort of tasks the reader would like to accomplish with Perl. The 11 categories of scripts are varied enough so as likely to be of use to just about anyone who would like to use the "Swiss Army knife of languages" for getting the job done on their computer, or that of their employer (as a system administrator). Personally I found most useful the scripts for detecting changed files, scanning Web sites for dead links, and parsing regular expressions.

There are other aspects to like about this book. It has a RepKover binding, to lay flat when open. The illustrations are clear and not excessive in number. Unlike some technical authors, whose weak attempts at humor simply make their obtuse material more annoying, Oualline is more subtle, such as his reference to the cost of Microsoft Windows CDs in a Hong Kong shop, or "Ingesting a Cheerio nasally." Well, perhaps not always subtle, but invariably welcome in what could otherwise be an extremely dry subject.

Like any book, there are some areas for improvement, perhaps in future editions: In the illustrations that employ rays pointing from one node to the next, some of the curved rays are remarkably jagged, as if they were not computer-generated. Far more importantly, some of the scripts could benefit from more internal comments, as well as having the code broken up into smaller functions, which improves clarity and maintainability. Also, some of the variables and functions could use more descriptive names. For instance, using two examples from a randomly chosen page: $file_name would be more clear than $cur_file (is it the file's name, full path, or contents?). print_file_cell() would be better than do_file() (do what to the file?).

But aside from those weaknesses, Wicked Cool Perl Scripts is a fine book that would be of interest to any Perl programmer, regardless of their expertise. In fact, the administrator of a Web site or a Linux/Unix server, would not even have to know the language in order to download these Perl scripts, and use them to solve problems on the job.

Michael J. Ross is a freelance writer, computer consultant, and the editor of the free newsletter of PristinePlanet.com.

You can purchase Wicked Cool Perl Scripts from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

239 comments

  1. Solve it by suso · · Score: 4, Funny

    Useful Perl Scripts That Solve Difficult Problems.

    Heh, Steve Oualline. In his book on Vim, he had this example of code where the program comment went something like this:

    /*
    Program -- Solve it -- Solves the worlds problems.
    All of them. At once.
    This will be a great program when I finish it.
    */

    1. Re:Solve it by with_him · · Score: 2, Funny

      I think he used a unifed shoe string theory for that solution.

    2. Re:Solve it by tcopeland · · Score: 4, Informative

      Yup, he's an excellent writer, and he's been cranking them out for quite a while. I've got his "Practical C Programming" book; it was written in 1991 but is still quite handy. Kind of like John Levine's lex/yacc book; classic stuff. Rereading that book shows pretty clearly that domain specific languages have been around for quite a while - although maybe they're a bit easier to write nowadays.

    3. Re:Solve it by QuietLagoon · · Score: 0, Troll

      Perl is an overly complicated, syntactically-challenged, unstructured kitchen sink of a language. The next major version of perl needs to be developed with more of a plan, and less of a "a little of this, and a little of that" philosophy.

    4. Re:Solve it by Anonymous Coward · · Score: 5, Insightful

      "There's more than one way to do it" should not be considered a personal challange to find them all

    5. Re:Solve it by Abcd1234 · · Score: 5, Insightful

      Perl is the most wonderfully architected, elegant, flexible language in the world. It's like a fully stocked kitchen with everything you'd ever need to get the job done, and more. Any new version of Perl would be a step backwards.

      See, we can both make absolutist, arbitrary statements with no basis in reality. Fun, eh?

    6. Re:Solve it by Jerf · · Score: 2, Interesting

      Perl is an overly complicated, syntactically-challenged, unstructured kitchen sink of a language. The next major version of perl needs to be developed with more of a plan, and less of a "a little of this, and a little of that" philosophy.

      Rest assured, Perl 6 has planning in abundance.

      You'll probably be less happy to learn that the guiding principle seems to be a "lot of this, lot of that" philosophy.

      But, this time with a plan.

      (My personal call on Perl 6? It's time to just ship it. Whatever "it" is. After a while the value lost to not having anything at all outweighs the cost of shipping nothing useful. Although, honestly, I'd rather see a useful Parrot that makes it possible to run Python, Perl, Ruby, and TCL through the same VM than Perl 6.)

    7. Re:Solve it by funfail · · Score: 1

      You both can, and you are absolutely both wrong.

    8. Re:Solve it by grcumb · · Score: 3, Interesting

      "Perl is the most wonderfully architected, elegant, flexible language in the world."

      Indeed. In fact, it's the only language in the world that can guarantee perfect software, every time. Even when you're drunk. 8^)

      --
      Crumb's Corollary: Never bring a knife to a bun fight.
    9. Re:Solve it by QuietLagoon · · Score: 1
      Rest assured, Perl 6 has planning in abundance

      That's what I have heard, and I hope the follow-through is there. I like perl, but it has some deficiencies. Deficiencies that if you happen to mention them here, you are modded down as a troll. A virtual pile-on, if you will.

      The concept of perl is an excellent one, however the value is in the execution of that concept. Prior to version 6, perl lacked in execution of its promise. I sincerely hope that version 6 changes that.

    10. Re:Solve it by Anonymous Coward · · Score: 0

      Tried the latter, didn't work out so well.

    11. Re:Solve it by newt0311 · · Score: 0

      yes, so elegant that it has inbuilt code encryption to the point where reading it can safely be considered a major acomplishement in of inself.

    12. Re:Solve it by chthon · · Score: 1

      There is another language called Arc with the same deficiency. Much talk and no shipping.

    13. Re:Solve it by Anonymous Coward · · Score: 0

      Didn't you pay attention in public school? Government is the solution to any concievable problem, and that's exactly why we need more of it.

    14. Re:Solve it by DuckDodgers · · Score: 1

      "There's more than one way to do it" should not be considered a personal challange to find them all

      Yes, but when you do things one way, she does things another way, and he does things a third way, you better be damn competent at all three or you can't maintain the code. Of course, that's true in most languages. It's equally easy to intentionally or accidentally obscure things by getting too fancy with the C preprocessor or pointer arithmetic.

      Java has a lot of faults, but it replaces pointers with single layer references and removes the preprocessor. In my experience, reading other people's Java code is worlds easier than reading other people's C, C++, and Perl - even if the code itself is poor or buggy. I'm sure there are other languages with a similar straightforward layout and syntax, but I've only worked with the four I listed.

    15. Re:Solve it by kalirion · · Score: 1

      Am I missing something? Couldn't you just have a class in Java along the lines of

      public class Acme {
          public final boolean isPerfect() {
              return true;
          }
      }

      that would accomplish the same thing? I'd think that the parent post was a joke, except that it's modded Interesting & Informative instead of Funny, so there MUST be something going on I'm not aware of, right?

  2. Good Practice? by neonprimetime · · Score: 2, Insightful

    In fact, the administrator of a Web site or a Linux/Unix server, would not even have to know the language in order to download these Perl scripts, and use them to solve problems on the job.

    Is these really that good of a practice though? Your pc's will be jam-packed with go you never wrote ... therefore you don't know what's actually going on with your own machines? Write your own scripts script kiddies.

    1. Re:Good Practice? by Cleon · · Score: 5, Insightful

      Admins that download scripts off the Net without even checking to see how they work are a danger to themselves and others.

      --
      Gifts for Geeks - Stuff that really matters!
    2. Re:Good Practice? by iamdrscience · · Score: 3, Funny

      Right, what's with people today, running programs other people have written? How can you be in control of your system if you didn't even write your own Operating System!!

    3. Re:Good Practice? by drinkypoo · · Score: 5, Insightful
      In fact, the administrator of a Web site or a Linux/Unix server, would not even have to know the language in order to download these Perl scripts, and use them to solve problems on the job.
      Is these really that good of a practice though? Your pc's will be jam-packed with go you never wrote ... therefore you don't know what's actually going on with your own machines? Write your own scripts script kiddies.

      Let's try this from another angle.

      "In fact, the administrator of a Web site of Unix/Linux server would not even have to know the language in order to download Apache, compile it, and use it to serve pages."

      "Is this really that good of a practice though? Your PCs will be jam-packed with software you never wrote ... therefore you don't really know what's going on with your own machines. Write your own programs, kiddies."

      (I corrected your spelling, grammar, and punctuation errors as well.)

      Basically, your argument amounts to absolutely nothing, because it's no different from other programs. Do you REALLY think that admins typically vet every line of code on their systems? People don't live that long. Know what the difference is between a C program you don't understand, and a perl script you don't understand? The C program is compiled once, and the perl script is JIT-compiled ever time you run it.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    4. Re:Good Practice? by Abcd1234 · · Score: 1

      Is these really that good of a practice though? Your pc's will be jam-packed with go you never wrote ... therefore you don't know what's actually going on with your own machines? Write your own scripts script kiddies.

      Yeah, no kidding! It's like all those lazy administrators that go installing arbitrary software from random third parties. I mean, do you have any idea what /usr/sbin/apache is actually doing? Write your own web server, I say! And don't get me started on all those so-called 'administrators' using /bin/bash...

    5. Re:Good Practice? by MindStalker · · Score: 1

      Guess the difference is the supplier and the code vetting process. MANY people have inspected apaches code and many more have used it sucessfully. While some script you find on the web is about as trustworthy as some shareware program you found on the web, I wouldn't trust either on a production server.

    6. Re:Good Practice? by Evil+Shabazz · · Score: 1

      If you're a developer and you've never used someone elses code to solve a problem you're either lying or stupid. That said, it's important to understand completely the code you didn't write before implementing it.

      --
      Down with the career politician! SUPPORT TERM LIMITS
    7. Re:Good Practice? by pjt33 · · Score: 1, Funny
      Know what the difference is between a C program you don't understand, and a perl script you don't understand?
      If you spend long enough reading the C program, you may come to understand it.
    8. Re:Good Practice? by sco08y · · Score: 0

      Basically, your argument amounts to absolutely nothing, because it's no different from other programs.

      Oh, bullshit. A script in a book omits all kinds of error-checking and security for brevity and clarity. A multi-megabyte download doesn't.

      And I doubt the publisher is going to release security fixes for these scripts. You don't see bugtraq saying, "hey, we found a possible buffer overrun in some sample code from this book."

    9. Re:Good Practice? by formerly+exchange+fo · · Score: 1

      It's a good thing. Like 'too rich' or 'too thin', you can never have 'too much good code'. Anyone who wishes to read the code (known good) has just saved themselves the pain of re-inventing the wheel. And you can 'stand on the shoulders of giants' who built the nuts and bolts and other tools which you can re-use. So if you had a problem, you would also have access to a bigger arsenal with which to attack that problem.

      --
      formerly of the exchange forum
    10. Re:Good Practice? by mkw87 · · Score: 1

      How's it going Linux?

      --
      Arguing with an engineer is like wrestling a pig in mud. Soon, you realize the pig is dirty, and he likes it.
  3. Sweet by Rethcir · · Score: 2, Funny

    These scripts are wicked friggen' pissah!

    1. Re:Sweet by Anonymous Coward · · Score: 0

      Yeah, the author is wicked schmaht!

    2. Re:Sweet by Rethcir · · Score: 1

      No, just smaht, no "sh"

  4. "Wicked" Cool? by necro81 · · Score: 4, Funny

    The author must be from Massachusettes, possibly the Cape?

    1. Re:"Wicked" Cool? by Profane+MuthaFucka · · Score: 1

      Wicked was what Ratt fans said in the 80's.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    2. Re:"Wicked" Cool? by misleb · · Score: 1

      No, if he was from Mass. it would have been written "Wicket"

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    3. Re:"Wicked" Cool? by takeya · · Score: 1

      I'm from New Hampshire originally Connecticut and I've grown up with the word Wicked in my vocabulary. It's New-England-Wide, man!

    4. Re:"Wicked" Cool? by VJ42 · · Score: 1

      Why? Do they play Cricket in Massachusettes; I didn't know that you Americans played the game.

      --
      If I have nothing to hide, you have no reason to search me
    5. Re:"Wicked" Cool? by PCM2 · · Score: 1

      I've heard it said by people from as far as Maine.

      --
      Breakfast served all day!
    6. Re:"Wicked" Cool? by navyjeff · · Score: 4, Funny
      To our readers on the West Coast:

      Please replace every instance of "Wicked" with "Hella" to improve readability.

      Thank you for your cooperation.

    7. Re:"Wicked" Cool? by Darby · · Score: 2, Interesting

      To our readers on the West Coast:

      Please replace every instance of "Wicked" with "Hella" to improve readability.


      That's only the Bay area.
      Even the rest of California really wants them to quit using that stupid sounding term.

    8. Re:"Wicked" Cool? by misleb · · Score: 2, Informative

      They can't pronounce the "d". They have trouble with "r" as well. They drive cahs. Wicket awesome cahs.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    9. Re:"Wicked" Cool? by kimvette · · Score: 1

      "wicked pissah" is more of a Revere thing than a Cape thing.

      --
      The Christian Right is Neither (Christian nor right). See: Matthew 23, Matthew 25, Ezekiel 16:48-50
    10. Re:"Wicked" Cool? by RPI+Geek · · Score: 1

      Agreed. One of my NH-based cousins told me about a time she was talking with a bunch of people from new england and one person from the midwest somewhere. She was talking about dirt bike riding and how someone "took a wicked digger" (translation: crashed hard). Everyone there got it except the person from the midwest... Even I understood when she told me the story.

      Just sayin.

      --

      - "Nobody came out that night, not one was ever seen. But Old Man Stauf is waiting there, crazy sick and mean!"
    11. Re:"Wicked" Cool? by takeya · · Score: 1

      That makes sense seeing as Maine is in New England

    12. Re:"Wicked" Cool? by WilliamSChips · · Score: 1

      My Latin teacher from Maine(who knows Stephen King personally, but that's a different story altogether) has used 'wicked' in such a way.

      --
      Please, for the good of Humanity, vote Obama.
    13. Re:"Wicked" Cool? by orcrist · · Score: 1

      That's only the Bay area.
      Even the rest of California really wants them to quit using that stupid sounding term.


      Really? I'm not even sure if it's the *entire* Bay area. When I moved from Berkeley to Marin County in 1989 I got grief from my friends all the time for using that :-P

      -chris

      --
      San Francisco values: compassion, tolerance, respect, intelligence
    14. Re:"Wicked" Cool? by Jedi+Alec · · Score: 1

      Please replace every instance of "Wicked" with "Hella" to improve readability.

      And this in a thread about cool Perl scripts?

      $article =~ s/Wicked/Hella/g

      Thank you, i'll be here all week...

      --

      People replying to my sig annoy me. That's why I change it all the time.
  5. yes and no by JeanBaptiste · · Score: 5, Insightful

    While it is important that the Admin completely understands what is going on.... theres no need to re-invent the wheel if someone else already went through the trouble of writing and testing it.

    1. Re:yes and no by finkployd · · Score: 5, Funny

      Personally, I don't think you truly understand how a wheel works until you reinvent one :)

      Finkployd

    2. Re:yes and no by JeanBaptiste · · Score: 1

      Well yeah.

      but...... I personally have never felt the need to write my own OS and Web server from scratch.

    3. Re:yes and no by finkployd · · Score: 3, Insightful

      I have not gone that far but I did write my own weblog in c forgoing the use of any libraries (like cgic) to make sure I knew exactly how web apps communicate with browsers. I didn't have to but now that I am rewriting it as a java servlet I have a much better understanding of what is going on behind the scenes.

      DIY is not always the answer, but in cases where the person is doing it for their own education I don't see a downside. There is also a compelling reason to do it for administration scripts were you will be responsible for fixing anything that breaks.

      Finkployd

    4. Re:yes and no by poot_rootbeer · · Score: 2, Insightful

      I agree that an admin need not reinvent the wheel, if pre-built wheels are readily available. But he should inspect it to make sure it's actually a wheel, and not just a pie pan, before he bolts it into the axle. Or at least know what a wheel looks like.

      The grandparent excerpt reads "the administrator of a Web site or a Linux/Unix server, would not even have to know the language in order to download these Perl scripts, and use them to solve problems on the job" -- implying that the admin not only doesn't need to WRITE the scripts he runs, but also doesn't need to READ the scripts he runs. That is foolish.

    5. Re:yes and no by syukton · · Score: 1

      Read my sig.

      --
      Reinvent the wheel only at either a lower cost, greater effectiveness, or your own personal enrichment and satisfaction.
    6. Re:yes and no by Anonymous Coward · · Score: 0

      Take a look at freshmeat or sourceforge. 90% of the projects are wheel reinvention.

  6. Re:All I want to know is... by neonprimetime · · Score: 4, Funny

    The Book? Of course ... but you'd need a power supply, motherboard, hard drive, processor, & memory

  7. Perl glue by Anonymous Coward · · Score: 3, Funny
    Perl has been called the glue that holds the Internet together.

    Hey, wait a minute! That's not glue... ewww... what is that? Larry, have you been touching yourself again?

    1. Re:Perl glue by Dutchmaan · · Score: 1

      Hey, wait a minute! That's not glue... ewww... what is that? Larry, have you been touching yourself again?

      That would be "pearl"

    2. Re:Perl glue by Anonymous Coward · · Score: 0

      That's not Larry. You're stuck in some PHP.

    3. Re:Perl glue by tool462 · · Score: 2, Funny

      There's more than one way to do it ;)

    4. Re:Perl glue by Anonymous Coward · · Score: 0

      So they get the name from the color?

    5. Re:Perl glue by Anonymous Coward · · Score: 0

      I'm sorry! It's coming apart! Must...make...more...

    6. Re:Perl glue by uberchicken · · Score: 0, Flamebait

      Huh.. a Perl necklace. Who'da thunk it.

  8. One of my favorites... by jizziknight · · Score: 1

    On Temple ov thee Lemur they have this crazy perl script. It's all on a single line and displays a realtime ASCII clock when run. Oh, it apparently also only runs on Linux.

    --
    Everything I say is a lie. Except that... and that... and that, and that, and that, and that... and that.
    1. Re:One of my favorites... by ajs318 · · Score: 1

      That probably is because they used literals for constants {which, let's face it, is a pretty standard practice in one-liners}. BSD and System V -- i.e., what was to become Solaris -- used different constants internally in some places. It was never an issue for software supplied in source form, because the correct values could always be got from the kernel headers {with a #include statement in C, for example, or a use statement in Perl}. Linux inherited a curious mixture of both and probably introduced some new ones of its own. So depending how you misuse literals, you might have scripts that work only on one operating system; or on Linux and Solaris; or only on Linux and BSD. If something works on BSD and Solaris, chances are it probably will work on Linux too.

      --
      Je fume. Tu fumes. Nous fûmes!
  9. Re:All I want to know is... by Anonymous Coward · · Score: 0
  10. Future wickedness by smittyoneeach · · Score: 4, Informative

    Audrey Tang thinks that Perl6 may be here before Vista, possibly even by the holidays...
    http://pugs.blogs.com/pugs/2006/06/yapcna_talk.htm l
    The slide show links show some terrifying code snippets.
    These Perl-merlins are wicked, indeed.

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    1. Re:Future wickedness by Anonymous Coward · · Score: 0

      > The slide show links show some terrifying code snippets.

      Dear lord, it's like a typewriter exploded on the screen.

      I love perl, but it's got to grow a new syntax. Making it *noisier* than perl5 (with the exception of $foo.bar instead of $foo->bar) was never a good start. It doesn't matter that it can get new syntax, it's actually got to be implemented.

      And sigils suck.

  11. Overhyped by Anonymous Coward · · Score: 0, Redundant

    Perl was simply a good tool for formatting the output from program A into the input for program B, which in the early days of the internet was very good when A and B werea Web server and Database. After that it simply became for a lot of people the hammer where everything looked like a nail...whether it was or not

    (and apropos that the verification word for the post is 'accident')

    1. Re:Overhyped by maximthemagnificent · · Score: 2, Interesting

      I learned perl coming from a c++, Java background and I found it really, really ugly.
      Not that I've learned any other scripting languages to have some comparison, admittedly.

  12. Let the religious flamefest begin! by mmell · · Score: 3, Funny
    In this corner - advocates of Perl, the Pathologically Ecclectic Rubbish Collector (or something like that)

    In that corner - advocates of Ruby (I haven't got a clue on this one, folks)

    And in this corner - dinosaurs like myself who still think awk/sed/sh is a pretty neat thing. Wait a minute, that's three corners. Uh . . .

    1. Re:Let the religious flamefest begin! by eln · · Score: 1

      Perl, the Pathologically Ecclectic Rubbish Collector (or something like that)

      PERC?

      Pathologically Eclectic Rubbish Lister, or sometimes Practical Extraction and Reporting Language. The first one is said to have come first, and was the "real" meaning of the acronym, but I think the second one is the more "official" meaning.

      As for awk, sed, and sh, I use them all the time for a lot of small scripts, but when I'm writing something that involves complex logic, I prefer to do it in Perl.

    2. Re:Let the religious flamefest begin! by Bromskloss · · Score: 4, Funny
      And in this corner - dinosaurs like myself who still think awk/sed/sh is a pretty neat thing. Wait a minute, that's three corners. Uh . . .

      Weep not, brave one, it's called a triangle and is perfectly normal.

      --
      Swedish plasma phys. PhD student; MSc EE; knows maths, programming, electronics; finance interest; seeks opportunities
    3. Re:Let the religious flamefest begin! by Amouth · · Score: 1

      the forth is the VB peps.. now we can have a good fight.. alteast it will be entertainaing

      --
      '...if only "Jumping to a Conclusion" was an event in the Olympics.'
    4. Re:Let the religious flamefest begin! by HardCase · · Score: 1

      In this corner - advocates of Perl, the Pathologically Ecclectic Rubbish Collector (or something like that)

      In that corner - advocates of Ruby (I haven't got a clue on this one, folks)

      And in this corner - dinosaurs like myself who still think awk/sed/sh is a pretty neat thing. Wait a minute, that's three corners. Uh . . .


      It's OK, you live in a triangle. Celebrate your inner trilateralness!

      But what's PERC?

    5. Re:Let the religious flamefest begin! by richdun · · Score: 2, Funny

      Ruby - Really User-friendly Buzzword Yeah!

      I dunno. Maybe that's why so many use redundant acronyms - one less word to think of.

    6. Re:Let the religious flamefest begin! by MrAnnoyanceToYou · · Score: 1

      .N00bs. You forgot the .Noo00OoOO0bs. The mercenaries of the code world.

    7. Re:Let the religious flamefest begin! by Anonymous Coward · · Score: 1, Insightful

      Python - Put Your Tin Hats ON!

    8. Re:Let the religious flamefest begin! by glwtta · · Score: 1

      Pathologically Ecclectic Rubbish Collector

      Hmm, PERC... the Dell RAID cards? Actually, I think your acronym fits those just fine.

      --
      sic transit gloria mundi
    9. Re:Let the religious flamefest begin! by nessus42 · · Score: 1, Troll
      In this corner ... Perl, ... in that corner ... Ruby...
      And the winner is... Python!

      |>oug

    10. Re:Let the religious flamefest begin! by grcumb · · Score: 2, Informative

      "Pathologically Eclectic Rubbish Lister, or sometimes Practical Extraction and Reporting Language. The first one is said to have come first, and was the "real" meaning of the acronym, but I think the second one is the more "official" meaning."

      Er, no. The word 'Perl' is a backronym.

      Wikipedia sez:

      Perl was originally named "Pearl", after "the pearl of great price" of Matthew 13:46. Larry Wall wanted to give the language a short name with positive connotations; he claims that he looked at (and rejected) every three- and four-letter word in the dictionary. He also considered naming it after his wife Gloria. Wall discovered before the language's official release that there was already a programming language named PEARL and changed the spelling of the name.
      --
      Crumb's Corollary: Never bring a knife to a bun fight.
  13. Perl? Bah! by Anonymous Coward · · Score: 5, Funny

    Anyone worth their salt would use an AJAX web 2.0 implementation of ruby on rails with a J2EE backend running struts marked up with DXHTML all bound together with an XML-SOAP web service to do their system administration via a proxied web cache. Changing configs would just involve editing a little CSS.

    1. Re:Perl? Bah! by Anonymous Coward · · Score: 0

      Buzzword Bingo!
      You WIN!!!!!

    2. Re:Perl? Bah! by richdun · · Score: 2, Funny

      I tried viewing this comment in IE, and all I got was a "BUZZWORD OVERRUN ERROR"

      Well done.

    3. Re:Perl? Bah! by Capt+James+McCarthy · · Score: 1

      Anyone worth their salt would use an AJAX web 2.0 implementation of ruby on rails with a J2EE backend running struts marked up with DXHTML all bound together with an XML-SOAP web service to do their system administration via a proxied web cache. Changing configs would just involve editing a little CSS.


      You forgot that this is powering a P2P interface, along with serving out Blogs and is running on Internet2.

      --
      There are no loopholes. It's either legal or it's not.
    4. Re:Perl? Bah! by Anonymous Coward · · Score: 0
      Anyone worth their salt would use an AJAX web 2.0 implementation of ruby on rails with a J2EE backend running struts marked up with DXHTML all bound together with an XML-SOAP web service to do their system administration via a proxied web cache. Changing configs would just involve editing a little CSS.
      And the resulting monstrosity would still be preferrable to Perl 9 times out of 10.
    5. Re:Perl? Bah! by wild_berry · · Score: 1

      Did it give the guy writing it privilege escalation to install .NET3, Vista and WinFS on your computer?

  14. Is this more useful by stratjakt · · Score: 4, Insightful

    Than googling for cool perl scripts?

    I'm asking seriously, because of all of the "cookbooks" and collection books of this sort that I've seen on the shelves at Borders, they're all full of things that a quick bit of googling could come up with. In fact, a little searching usually yields better solutions, and I'm convinced they're written by copy/pasting google results into the author's editor of choice.

    I'm all for good dead-tree reference material, but I've been frustrated trying to find books that don't contain stuff-i-already-know, or stuff-i-can-get-free on the 'net.

    I guess it can't be good for the dead tree tech manual industry, but so long as universities and colleges force students to buy the books (and a new revision of the same book every year), that's all fine and good.

    --
    I don't need no instructions to know how to rock!!!!
    1. Re:Is this more useful by Anonymous Coward · · Score: 0

      How do you think you write books like these to begin with?

    2. Re:Is this more useful by Tankko · · Score: 3, Interesting

      I have a bunch of "cookbooks", and I don't read them because I'm looking for a specific solution, I read them because it's a great way to learn a lot of tricks and see a lot of code in a concentrated place that covers a bunch of areas.

      I sit on the couch and just read them and learn a lot.

    3. Re:Is this more useful by Sean+Riordan · · Score: 1

      The books are still useful for browsing to learn new ideas. More so when offline for travel or whatever.

      Having originally come upon Perl kinda sideways and in a very narrow niche looking at how others were using it was a good thing. I started using it because it provided a back door method of sending commands through a truly horrid and unwieldy ground system I was once forced to use for a year or so. Now I use it quite regularly for more 'normal' activities as well as dynamically creating code in another less feature rich language.

      --
      Sig? What if I prefer Glock?
    4. Re:Is this more useful by chromatic · · Score: 1

      You might prefer Perl Hacks then.

      I guarantee that it contains a few things you have never seen before.

  15. Solve it, Fixed version by fprog26 · · Score: 2, Interesting

    Your solution was a bit too C++ and won't compile with perl, so you probably meant the following... :)

    #!/usr/bin/perl
    #
    # Program -- Solve it -- Solves the worlds problems.
    # All of them. At once.
    # This will be a great program when I finish it.
    #

    sub main()
    {
    # no idea at all...
    }

    main();
    exit;
    1;
    __END__

    or the even better, the POD way:

    #!/usr/bin/perl

    =head1 GOAL
    Program -- Solve it -- Solves the worlds problems.
    All of them. At once.
    This will be a great program when I finish it.
    =cut

    sub main()
    {
    # no idea at all...
    }

    main();
    exit;
    1;
    __END__

    1. Re:Solve it, Fixed version by Anonymous Coward · · Score: 2, Funny

      #!/usr/bin/python

      from __future__ import solutions

      solutions.solveTheWorldsProblems()

    2. Re:Solve it, Fixed version by rgmoore · · Score: 5, Interesting

      That looks as though you don't know Perl very well. There's no need for a separate main routine, as whatever is in the file that's not part of another subroutine is assumed to be part of main. There's also no need to have the program end in a true statement (that's necessary only for modules) or to use an __END__. In the true spirit of Perl (i.e. eliminating needless elements) here's a refined version:

      #!/usr/bin/perl

      =head1 GOAL
      Program -- Solve it -- Solves the worlds problems.
      All of them. At once.
      This will be a great program when I finish it.
      =cut

      use warnings;
      use strict;

      #Do something here

      exit;
      --

      There's no point in questioning authority if you aren't going to listen to the answers.

    3. Re:Solve it, Fixed version by eln · · Score: 5, Insightful

      The exit statement at the end is unnecessary.

    4. Re:Solve it, Fixed version by boaworm · · Score: 1

      Sorry, but that would generate a null-pointer.

      --
      Probable impossibilities are to be preferred to improbable possibilities.
      Aristotele
    5. Re:Solve it, Fixed version by rgmoore · · Score: 1

      Technically the use warnings; and use strict; aren't necessary either; at the very least there are far too many people who don't seem to use them. I've just gotten in the habit of using all of them. The warnings and strict are obvious, and I like to put an exit at the end of my main program both to mark where it ends and the subroutines begin.

      --

      There's no point in questioning authority if you aren't going to listen to the answers.

    6. Re:Solve it, Fixed version by Metasquares · · Score: 2, Informative
      You can write part of this program even more efficiently in Perl 6:
      sub main()
      {
      ...
      }
      It's called the "yadda yadda operator" and it is actually valid Perl 6 syntax.
    7. Re:Solve it, Fixed version by Anonymous Coward · · Score: 0

      That's what I love about Perl: the more code you take out, the better it gets.

    8. Re:Solve it, Fixed version by Anonymous Coward · · Score: 0
      more like
      $ perl -we "# Do something"
    9. Re:Solve it, Fixed version by Jahz · · Score: 1
      Actually, if you really wanted to rewrite it in the true spirit of Perl, you would have removed all that wasteful whitespace.
      #!/usr/bin/perl =head1GOAL Program -- Solve it -- Solves the worlds problems. All of them. At once. This will be a great program when I finish it. =cutusewarnings;usestrict; #Do something here exit;
      --
      There are 10 types of people in the world. Those who understand binary and those who do not.
    10. Re:Solve it, Fixed version by 1234butt · · Score: 1

      Considering that the program does absolutely nothing, all that's necessary is the first line.

    11. Re:Solve it, Fixed version by Sean+Riordan · · Score: 1

      Hm ... I have always been given the impression that not using warning and strict would generate a quantum tar and feathering to the perl monkey silly enough to forget them, unless it was a deliberate obfuscation piece.

      --
      Sig? What if I prefer Glock?
    12. Re:Solve it, Fixed version by AGMW · · Score: 1
      There's no need for a separate main routine ...

      In a nutshell, that's what I don't like about perl. There's so many default actions that mean you don't need to write the code to do all sorts of things and, IMHO, that just makes it unmaintainable. Sure, if you're the perl-kid then it's all obvious to you and you can exercise your skills by writing ever more terse scripts that requires someone of equal or greater skill to be able to make any changes.
      I just don't see the problem with having a "main" (or whatever) typed into the script to indicate where the script starts, and END somewhere to show where it ends. What are you saving by leaving them out? Aren't you just polishing up your ego?

      --
      Eclectic beats from Leeds, UK
      handmadehands.co.uk
    13. Re:Solve it, Fixed version by qwijibo · · Score: 1

      Technically, that's only true if you want to call the program that does nothing from your path. Otherwise, the most perfect perl implementation of no functionality is either an empty file or a null command.

      % touch foo
      % perl foo

      Alternatively:

      % perl -e ''

  16. OB Ruby fanboyism by Teach · · Score: 2, Informative

    You know, I love Perl. I've been using it for CGI stuff, for system-administration stuff, etc, for six or seven years now.

    In fact, the only things I haven't written in Perl during that time have been things that were either too lightweight (five line shell scripts) or too in need of structure (a free/Free clone of Advance Wars in Java).

    That said, every new script I've written so far this summer has been written in Ruby. I hate to sound like a Ruby fanboy, but I think Ruby is really a better perl than Perl.

    Ruby is good at everything that Perl is good at (regular expressions, CGI, process control, text munging) and has equally rich built-in libraries. However, Ruby is also good at the things that Perl isn't good at. You've got real objects when you want them. LISP-like things like iterators and closures. The works.

    Ruby's only major flaws at the moment are: 1) it doesn't have anything like CPAN (yet), and 2) interpreter speed is still fairly slow relative to older, more optimized interpreted languages like Perl or Python.

    I do agree that Steve Oualline is a badass, and that Perl is pretty wicked.

    But you fans of Perl should give Ruby a try, especially if you know some LISP or Scheme and occasionally miss Perl's difficulty in creating something as simple and rigid as a C struct.

    --
    Graham "Teach" Mitchell, computer science teacher, Leander HS
    1. Re:OB Ruby fanboyism by Billosaur · · Score: 2, Insightful
      However, Ruby is also good at the things that Perl isn't good at. You've got real objects when you want them.

      Hey!! Perl has real objects... you just have to work at it...

      Of course, being a Perl programmer, I am very averse to work, hence all the time I spend reading Slashdot.

      --
      GetOuttaMySpace - The Anti-Social Network
    2. Re:OB Ruby fanboyism by Abcd1234 · · Score: 1

      I agree, Ruby looks like a nice language (basically an actually useful Smalltalk workalike... something I can really appreciate). However, when it comes right down to it, I use Perl for two reasons:

      1) CPAN
      2) ubiquity

      'course, you've already mentioned CPAN, but it's an important point to reiterate. The power of Perl, in large part, lies in the massive number of third party libraries available. As for ubiquity, it's rare these days for me to ssh into a machine that doesn't have Perl. The same can't be said for Ruby. Unfortunately for Ruby, this is a vicious cycle... unless people switch, it won't be ubiquitous. And It won't be ubiquitous until people switch.

    3. Re:OB Ruby fanboyism by Anonymous Coward · · Score: 1, Informative

      Isn't RubyGems specifically for CPAN-like functionality? I realize it's nowhere near as mature as CPAN, but Ruby isn't as mature as Perl either, is it?

      http://docs.rubygems.org/read/book/1

    4. Re:OB Ruby fanboyism by Anonymous Coward · · Score: 0

      Reason #3: My boss (or, if you want to be less personal, my workplace standards) don't let me use Ruby over Perl. We all need to program in the same language!

      This post obviously duplicates other people's comments -- the chicken and egg problem of getting Ruby into the mainstream.

    5. Re:OB Ruby fanboyism by nuzak · · Score: 4, Insightful

      I have those two reasons, but those are soft factors, nice-to-have, but not necessary. Unfortunately, I have a third:

      3) unicode

      I have to deal with lots of unicode, index it, run regexes on it, and so on. Ruby lacks any real unicode support, which has made it a deal-breaker.

      --
      Done with slashdot, done with nerds, getting a life.
    6. Re:OB Ruby fanboyism by Anonymous Coward · · Score: 0

      Perl has both closures and objects.

      Perl is also vastly faster when it comes to any sort of string handling.

    7. Re:OB Ruby fanboyism by loquacious+d · · Score: 2, Interesting

      I agree on all points. I also find the average Ruby script infinitely more readable than most of the Perl I've read (or written). Ruby's syntax is just so perfect and clean. I was pretty skeptical when I first started reading Ruby books, the way everyone always waxed so ridiculously lyrical about how writing Ruby after using other languages was like a walk in a park on a damp spring day with the sun just barely shining through the low wispy fog etc. etc. etc. But it's true. I hope it can maintain its momentum, the world would be a better place if people spent as much effort learning/improving/extending Ruby as they did Java (*shudder*).

    8. Re:OB Ruby fanboyism by mypalmike · · Score: 0, Troll

      In fact, the only things I haven't written in Perl during that time have been things that were either too lightweight (five line shell scripts)...

      Five line scripts are about as much Perl as you can write before you give up maintainability. Don't get me wrong, though. Perl is great for those five line scripts.

      --
      There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
    9. Re:OB Ruby fanboyism by glwtta · · Score: 3, Insightful

      You've got real objects when you want them. LISP-like things like iterators and closures. The works.

      I don't want this to degenerate into rabid fanboyism, but it seems the benefits of a "real" (or, real, if you preffer) object system over Perl's are routinely exaggerated. Yes, it could be better, but for 95% of the things you do, it works just fine.

      And of course Perl has iterators and closures (and first order functions, and all that other hard-to-maitain stuff the Functional crowd always goes on about). It's probably one of the things I like best about Perl, it just has features as part of the language, no one makes a huge deal of it.

      I've looked at Ruby (ok, glanced), and I just can't stomach the syntax - it's like writing Java in VB. Entirely subjective, of course. Though, as long as I live I will not understand this recent fad of trying your best not to delimit code blocks clearly - it smells of choosing ideology over utility.

      Definitely agree about the lack of "simple and rigid" struct-like things, I miss those often.

      And of course for anyone who wants a feature that Perl doesn't have, there's Perl 6 - that will have every feature that has existed in any language, ever.

      --
      sic transit gloria mundi
    10. Re:OB Ruby fanboyism by Phroggy · · Score: 1

      My understanding is that Perl doesn't have real objects, it just lets you pretend that it has objects, and everything basically works.

      So my question is, what would I want to do with objects that a language like Ruby would let me do (because Ruby has real objects), but I can't do (as easily) in Perl (because Perl doesn't have real objects)? Other than preventing myself from directly accessing an object's internal workings, which breaks the concept of OOP but isn't a problem if I simply choose not to do it.

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    11. Re:OB Ruby fanboyism by sheetsda · · Score: 1

      I had to write a term paper back in college where I compared two languages assigned to me, mine happened to be Ruby and Python. I knew neither at the time. Since I already knew Perl, I threw in little tidbits about it as well. One of the things that impressed me the most (and this may have changed in the past 3-4 years) was if I wrote something where whether or not a variable had a binding was determined at run-time like

      $blah = ;
      chomp $blah;
      if ($blah eq 'a') {
                      $b = 1;
      }

      print $b;

      in all three languages, Ruby was the only one that bombed out during parsing, before anything ever ran. When I saw that I instantly became a fan. In either of the other two languages that could have become a nasty surprize down the road. (Yeah, the above is a Perl fragment. So sue me.)

    12. Re:OB Ruby fanboyism by Anonymous Coward · · Score: 1

      You are a piss poor programmer if you believe that. I have looked at Perl programs with many THOUSANDS of lines of code and it was well written and *easy* to follow.

      I do agree that Perl makes it easy to write bad code but so what.

      "With great power comes great responsibility"

    13. Re:OB Ruby fanboyism by Goaway · · Score: 1

      Except of course you should have been using strict in Perl, which would have made it a moot point. Neither Python nor Ruby have an equivalent, however.

    14. Re:OB Ruby fanboyism by Abcd1234 · · Score: 1

      Ahhh yeah, I knew there was one major drawback to Ruby, but couldn't recall what it was. Though, it's interesting to note that it wasn't until Perl 5.8.0 (around four years ago) that it really supported Unicode (as in, full regex support). By comparison, Ruby is fairly immature, so it should be interesting how it progresses on this front. OTOH, it's rather surprising surprising to me that, given Ruby's age, Unicode wasn't designed in from the beginning...

    15. Re:OB Ruby fanboyism by jonfelder · · Score: 1

      Put this at the top of your fragment:

      use strict;

      You should put this up there too:

      use warnings;

    16. Re:OB Ruby fanboyism by Abcd1234 · · Score: 1

      I have a better idea. Define 'real object'. However, before doing so, compare and contrast Perl's object system to those found in Python and Javascript, both of which are considered object-oriented.

    17. Re:OB Ruby fanboyism by esper · · Score: 3, Interesting

      "Inside-out objects" can give you hard data hiding. Basically, instead of storing the object properties as keys of a blessed hash, you have a file-scoped (my) array for each property. Nothing outside of that file can access the data and the object becomes a blessed integer reference (used as an index into the property arrays) instead of the blessed hash reference that's normally taught. (This can also be implemented with hashes for each property and the blessed reference itself used as the hash key, but I tend to prefer the array version, since the lookups are a good deal faster.)

    18. Re:OB Ruby fanboyism by Anonymous Coward · · Score: 0

      I am well aware of use strict;, my point is it is flat out better to have it refuse to parse without importing an extra module. Suppose I wanted to use the nonstrict approach for whatever reason. Surely with all the unfathomable possible applications of Perl scripting you're not willing to assume that there is no valid reason for not using the strict module. (I do not claim to know one off the top of my head, but I am unwilling to say that such a reason does not exist)

    19. Re:OB Ruby fanboyism by myowntrueself · · Score: 2, Funny

      My understanding is that Perl doesn't have real objects, it just lets you pretend that it has objects, and everything basically works.

      s/objects/anything/g

      --
      In the free world the media isn't government run; the government is media run.
    20. Re:OB Ruby fanboyism by Phroggy · · Score: 1

      Right, I've heard of that. Thanks for the reminder... but like I said, it's not a problem if I just choose not to access the internals of the object.

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    21. Re:OB Ruby fanboyism by shish · · Score: 1
      there's Perl 6 - that will have every feature that has existed in any language, ever.

      And that's exactly why brainfuck is easier to understand...

      (Seriously; whenever I compare someone else's perl to my own it's like an entirely different language -- because "there's more than one way to do it", you have to understand *every* possible way of doing it if you want to understand other people's code~)

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    22. Re:OB Ruby fanboyism by chthon · · Score: 1

      Perl does have closures. Probably the only thing missing are iterators, but then no Scheme or Common Lisp has iterators either.

      The only reason why I use Perl is its abundant supply of libraries. If I had the same libraries and possibilities as Perl in Common Lisp, I would only use Common Lisp. SBCL and CMUCL have damn fine optimising compilers, which are able to get near C-speeds from Common Lisp code.

      Otherwise, I like Perl, because I can almost do the same things with Perl as with Common Lisp. Only macros are more difficult.

      And for object-oriented principles : Paul Graham has shown in his book, ANSI Common Lisp, that with a language like Lisp, it is rather trivial to implement a small OO layer which can solve most of your problems.

      That is what happens in Perl, the basic power of the language makes it possible to implement OO in it, without additional syntax.

    23. Re:OB Ruby fanboyism by ErikZ · · Score: 1

      If Perl is such a good language, shouldn't that be the default behaivor? Instead of having to add it in there for every script you write?

      --
      Democrats or Republicans. They are both taking us to the same place and they are not afraid of us anymore.
    24. Re:OB Ruby fanboyism by jonfelder · · Score: 1

      I believe the reasoning is for reverse compatiblity with older scripts. I think perl 6 may make use strict the default.

      Why are you so combative? I never said perl was better than ruby or python (I do like it, however), I merely said it had the feature they said it lacked. That doesn't imply that I think it's better, no does it imply that I think it's worse.

    25. Re:OB Ruby fanboyism by ErikZ · · Score: 1


      That was my first post on this topic, but my history with Perl is...

      It took me several days to get a very basic perl script to work. The error messages for a non-functioning script are horrible.

      I ended up trying to get help from the #perl channel on IRC. I was dressed down for presenting them with a script that didn't have those switches turned on, that I had no idea existed. Went and fixed it up just the way they wanted it, and was told my issue was with the module I was using at the time. No way to have known it acted like that without experience.

      Writing out a few lines of code shouldn't be an exercise in frustration; at least with C you get a decent debugger. I'm learning Ruby and it's been wonderful so far.

      --
      Democrats or Republicans. They are both taking us to the same place and they are not afraid of us anymore.
    26. Re:OB Ruby fanboyism by jonfelder · · Score: 1

      So basically your reasoning for being a prick was that someone else was a prick to you. Great.

      That's the great thing about there being multiple languages and multiple ways of doing things. People get to choose to use the tools they like in the way they like.

  17. Fine, but about the title... by danelav · · Score: 2, Insightful

    Why is it that every scripting book needs a title that sounds like it was written by a 14-year old?

    1. Re:Fine, but about the title... by misleb · · Score: 1

      In New England, "wicked" isn't just for 14-year olds. ;-)

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    2. Re:Fine, but about the title... by rp · · Score: 1

      Philip Greenspun has answered this rather clearly, imho.

  18. Now that is a cool poll by WebHostingGuy · · Score: 1

    Which will arrive first?

    Vista

    or

    Perl 6

    The race is on...

    --
    Quality Hosting e3 Servers
    1. Re:Now that is a cool poll by smittyoneeach · · Score: 1, Funny

      I think that Audrey Tang is packing more heat than Microsoft, but that's just an opinion. ;)

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    2. Re:Now that is a cool poll by audreyt · · Score: 5, Funny

      ...and I would be inclined to agree. :-)

    3. Re:Now that is a cool poll by Anonymous Coward · · Score: 0

      D'oh, modded without looking at the name (-red face-). Sorry. Maybe posting this will undo?

    4. Re:Now that is a cool poll by !Freeky2BGeeky · · Score: 1

      ... And which will have fewer bugs?

      --

      Visualize Whirled Peas

    5. Re:Now that is a cool poll by VGPowerlord · · Score: 1

      I choose Duke Nukem Forever!

      Wait... can I change my vote?

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
  19. Space = Money by Mick+Ohrberg · · Score: 1
    ...every one of the scripts contains a POD (Plain Old Documentation) section, though only in the downloadable version -- not the version seen in the book, to save space.

    I thought these people got paid per page?

    --

    Quidquid latine dictum sit, altum sonatur.

    1. Re:Space = Money by Architect_sasyr · · Score: 1

      I thought these people got paid per page?

      Maybe they do.. but to some of us in the OSS world, the satisfaction of hacking some good code, or (as the case may be) writing a good book, is enough payment for us. I don't speak for every geek, but so long as I make enough money to be in rent and computers (and coffee) I am happy with my lot. I will continue to submit my code for the world to use, and I pray to the BSD-Gods that others will continue to do this also.

      My $0.02 (Aus).. Cheers.

      --
      Me failed English...
      FreeBSD over Linux. If my comments seem odd, this may explain...
    2. Re:Space = Money by Mick+Ohrberg · · Score: 1

      I know :) It was a lame attempt at humor - dry such. Some of the greedier people out there will never understand the driving force behind people like RMS, Phil Zimmerman, Linus, and all the other major contributors to FOSS.

      --

      Quidquid latine dictum sit, altum sonatur.

  20. Wicked Cool Series... by Anonymous Coward · · Score: 0

    I have their book "Wicked Cool Shell Scripts" it's not the best reference, and it's not the most complete. On the other hand, it's perfect for examples, some basic idea of shell scripting, and is very well written. It was also quite inexpensive, when compared to the other books on the shelf at the time.

    If this book is on par with that, I'd personally have no trouble buying it - despite that I'm not particularly fond of perl.

    http://www.amazon.com/gp/product/1593270127/sr=8-2 /qid=1151524691/ref=pd_bbs_2/002-0411526-9137664?i e=UTF8

  21. Gaah, that was in a book? by coyotecult · · Score: 2, Informative

    Worlds = world's! I know it's in a code comment, but eeeeesh. Apostrophes are friends!

    1. Re:Gaah, that was in a book? by lgw · · Score: 1

      An Apøstrøphe once bit my sister.

      Apøstrøphe bites can be nasty.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    2. Re:Gaah, that was in a book? by trandism · · Score: 1

      are you sure about that?

      what if we then parse the file searching for comment using... ahem... PERL and insert them into a MySQL database..

      Will apostrophs still be friends?

      --
      www.lemonodor.com A mostly Lisp weblog
    3. Re:Gaah, that was in a book? by scatters · · Score: 1

      Almost as bad as a møøse bite.

      --
      A One that isn't cold, is scarcely a One at all.
    4. Re:Gaah, that was in a book? by Anonymous Coward · · Score: 0

      Sure, if you follow the documentation and use the proper functions to escape your strings.

  22. the relationship between Perl and C by kisrael · · Score: 2, Informative

    I've been a street-taught Perl hacker since like 1993 or so.

    Only recently, despite having read a lot of the Perl books and hung around online a lot, I found about the history of Perl that I almost couldn't believe...that originally, it was just a glue language for a big honking chunk of Unix system calls, mostly written in C.

    My credulity is because Perl sometimes seems like the anti-C...especially in terms of handling strings, since my memory of C is using chararrays for everything.

    But it makes sense.... C offered blazing speed, and Perl was a great duct tape glue for all that. It's amazing that it had such quality memory management, string handling, associative arrays, and loosey goosey syntax for reg ex etc. But it's great.

    I think it falls apart once you get to the perl 5 object model, which I've never been able to really get my head around... but for anything that should be written programatically rather than structured from objects, it's really great.

    --
    SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    1. Re:the relationship between Perl and C by Phroggy · · Score: 4, Insightful

      I don't see how you could read any books about Perl and not have any idea where the language came from. This is why PHP is so much more popular than Perl among people who don't already have a familiarity with UNIX and C: a C programmer learning Perl can say "oh hey, perl has a localtime() function, I already know how to use that" while a newbie will say "wtf, why do months start with 0 and the year is 106, and how am I supposed to remember what order all these numbers are in?" A UNIX hacker can say "oh hey, $0 and $$ are exactly the same as they are in shell scripts, and the regex syntax looks just like sed" while a Windows user will say "wtf, what are all these meaningless variables, and what the hell is a regex?"

      My advice for OOP in Perl:
      1) learn how OOP is supposed to work in some other language
      2) pretend that it works that way in Perl, and try not to think about how "bless" actually works.

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    2. Re:the relationship between Perl and C by kisrael · · Score: 1

      I don't see how you could read any books about Perl and not have any idea where the language came from.

      Well, I was well aware of the "weird UNIXisms" in Perl, but I kind of thought that functions like localtime() were still "weird" in Perl because Wall et al. wrote them to be slantwise compatible with what C programmers on the system new, not that they were all pretty much straight passthroughs.

      It still blows my mind, actually, that such a loosely typed language has straight pass througs to misc. Unix C functions, just because C is so strongly typed.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    3. Re:the relationship between Perl and C by kisrael · · Score: 1

      Another note: you bring up the hypothetical C programmer who used localtime() and Unix hacker who used sed... honestly I think both of those people are from an earlier era, in that I think people get exposed to Perl now before they get exposed to Unix system calls and sed.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    4. Re:the relationship between Perl and C by mrsbrisby · · Score: 1

      My advice for OOP in Perl:
      1) learn how OOP is supposed to work in some other language
      2) pretend that it works that way in Perl, and try not to think about how "bless" actually works.


      And by "some other language", you mean C++ or PHP, right?

      The problem is _those_ aren't Object Oriented languages- they're class-oriented, and so they have a strict taxonomy for all objects. Perl's object orientedness is much more like Smalltalk, Objective-C, and Ruby (and to a lesser extent: Java), and it _indeed_ works that way. Think of -> to mean "message send" instead of "method call" and it'll make a lot more sense.

    5. Re:the relationship between Perl and C by Phroggy · · Score: 1

      And by "some other language", you mean C++ or PHP, right?

      I actually was thinking of Java, since it was while taking a Java programming class that OOP first clicked for me. I almost never recommend PHP for anything. :-P

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    6. Re:the relationship between Perl and C by mrsbrisby · · Score: 1

      I actually was thinking of Java, since it was while taking a Java programming class that OOP first clicked for me. I almost never recommend PHP for anything. :-P

      I am so, so, sorry.

    7. Re:the relationship between Perl and C by Phroggy · · Score: 1

      Perhaps I should mention that I dropped out of the class and never used Java again?

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
  23. Re:Yes... by Vorondil28 · · Score: 1

    What the hell man, it's a book review. Since when is it a slow news day when Slashdot puts one of it's many, community contributed book reviews on the front page?

    *Sigh* Why am I bothering, you're just a troll...

    --
    This sig rocks the casbah.
  24. Perl praise and beefs interspersed by tinker_taylor · · Score: 5, Insightful

    A humble Perl user's thoughts on this brouhaha --

    Praise
    =======

    1) The power of perl is irrefutable -- it helps slap together quick and clean solutions to irritating admin problems. The flip-side of being a perl jockey I guess is that one tends to try and create a solution to many a problem that already has a solution - because searching CPAN can be a pain at times.

    2) Use of the more flexible features of the languages (such as Hashes, hash of hashes etc) data/number munging and organization becomes more manageable.

    3) Using Perl's almost endless modules, a lot of relatively complicated tasks can be simplified.

    4) Annoyance factor of numerous tasks (especially Administrative and reporting) can be reduced drastically with the help of Perl.

    Beefs
    =====

    1) The beef I guess is that unlike Python or Perl's other competitors, Perl modules don't come tightly integrated with the core distro. Agreed that Perl probably has a lot more modules than any of those other languages do, but a larger than ordinary de facto distribution (why not include important modules like Digest::MD5, Crypt modules, SSH modules etc?) would be desirable (especially in those situations where you don't have access to the internet directly from within corporate networks and can't install the modules with the "perl -MCPAN -e shell" option) . There might be those Perl veterans who would say -- "build your own distro with your custom modules already packaged" -- and while that might be a very smart thing to do, many a time (when one keeps moving from one environment to another -- some call it job hopping, it helps to be able to download one single perl distro package or rpm or the source+compile and have basic administrative scripts work -- especially those that rely on centralized automation (ssh-based trusts, copies across the network, etc).

    2) Also, perl's syntax can be terse and difficult for noobies to understand (or even older perl-hands for that matter -- when someone has written code without appropriate comments, etc).

    3) Tinkering with Python recently, I found it's simplicity refreshing and it's syntax easier to comprehend (especially when compared with Perl's (imho) complicated "scoping" requirements, etc).

    4) Sometimes (and I guess it depends on the person writing the code) Perl tends to over-complicate things that can be easily handled via Shell scripts.

    1. Re:Perl praise and beefs interspersed by VGPowerlord · · Score: 1

      perldoc perlmodlib tells you which modules come with perl.

      In the 5.8 version of, one modules such module is Digest::MD5. The core crypt() function also passes things directly through to the OS's crypt library. However, for portability reasons, you should use Crypt::PasswdMD5 for MD5-base crypted passwords, as some libraries (such as Windows') don't support MD5 hashes.

      Having said that, I have my own list of things I dislike about perl.

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    2. Re:Perl praise and beefs interspersed by Phroggy · · Score: 1

      1) The beef I guess is that unlike Python or Perl's other competitors, Perl modules don't come tightly integrated with the core distro. Agreed that Perl probably has a lot more modules than any of those other languages do, but a larger than ordinary de facto distribution (why not include important modules like Digest::MD5, Crypt modules, SSH modules etc?) would be desirable (especially in those situations where you don't have access to the internet directly from within corporate networks and can't install the modules with the "perl -MCPAN -e shell" option) . There might be those Perl veterans who would say -- "build your own distro with your custom modules already packaged" -- and while that might be a very smart thing to do, many a time (when one keeps moving from one environment to another -- some call it job hopping, it helps to be able to download one single perl distro package or rpm or the source+compile and have basic administrative scripts work -- especially those that rely on centralized automation (ssh-based trusts, copies across the network, etc).

      I completely agree, this is a huge problem. Unfortunately, everyone has a different opinion of what "the important modules" are - for example, you mentioned SSH, and I don't think I've ever seen an SSH module, certainly never used one myself, and I don't think I've seen one required by anyone else's code. This is a good place to start, but several of the modules there have external dependencies (e.g. DBD::mysql, GD, and Net::SSLeay, all on the top-10 list) and you really can't expect the libraries they depend on to be installed on everything (although OpenSSL probably ought to be).

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    3. Re:Perl praise and beefs interspersed by tinker_taylor · · Score: 1

      I guess the point I was trying to make was this: 1) The advantages of perl are plentiful 2) There are several obvious shortcomings as well (at least to "not-yet-perl-god" like users such as myself -- folks who are trying and learning perl as they go along (and I've been doing this for over 6 years now)) -- improvising as required. We need the language to become easier and smarter -- with the syntax becoming easier to comprehend (terse regex patterns might give a great sense of satisfaction to match, but when you're in a time crunch, it's the kind of stuff one could do well without). But I guess at the end of the day, the newer the language, the better the odds of it being more refined/advanced that it's older predecessor are.

  25. Wicked Cool is Passé... by JoshDM · · Score: 1

    ...now if it was Wicked Awesome, I'd be more inclined!

  26. Re:Clarification by Vorondil28 · · Score: 3, Interesting
    You're argument against Perl is:
    1. Slashdot is written in Perl.
    2. I don't understand the error message I got when attempting to post on Slashdot.
    3. Therefore, Perl code is incomprehensible and unmaintainable.


    You, sir, are a veritable fount' of wisdom...</sarcasm>
    --
    This sig rocks the casbah.
  27. I'm not impressed by cerelib · · Score: 3, Insightful

    It seems as if all they did was wrote a basic clock program and then ran it through an obfuscator or two. You can get a few obfuscation modules on CPAN. Anybody can run a program through obfuscators. Ever tried to look at the google maps javascript?

    1. Re:I'm not impressed by Anonymous Coward · · Score: 0

      Google's code has truncated names to save on bandwidth, not to confuse people.

    2. Re:I'm not impressed by cerelib · · Score: 1

      I am not a javascript guy, but this code does seem to be obfuscated. The truncated names seem to be only part of it. It seems as if they have filtered their code in such a way that almost every line has been turned into a function. Here is an example of a completely useless function:
      function C(a,b,c){a.setAttribute(b,c)}

      There is no reason the above code should be encapsulated into a function. Knowing that, the meaningless function names seem to be for both obfuscation and bandwidth saving. If they wanted only to save bandwidth they would not have these types of functions because every time a function is a added they need to add the text "function" and the parameter list. Her is another prime example of why I think this is obfuscation:
      function v(a,b,c,d){return mb(a,b,Q(c,d))}

      Go back to the code and follow some of these functions around. I think you will see that 1. this code was run through some form of filter and 2. while bandwidth is a concern, this filter serves to obfuscate human readable code. That is just my take on it.

  28. Re:Clarification by Anonymous Coward · · Score: 0

    My argument against Perl was that it is incomprehensible and unmaintainable. It seems you can't even read.

  29. NOT Worth While by Anonymous Coward · · Score: 2, Informative

    If you've hacked Perl for over a year this book is major disapointment. The examples are all largely available elsewhere and relatively uninspired things such as simple CGI web counters. Buy some O'Reilly stuff instead.

  30. Write yes, read not so much by Sarusa · · Score: 3, Interesting

    'Of all the popular programming languages now in use, Perl is perhaps the best suited for writing utilities'. I would probably agree with this - you can very easily hack out a very simple utility to do something with less effort and code than in Ruby or Python. Of course if you ever need to read it again, or god forbid extend it, then the extra effort you put in up front may pay off.

    Yes, I know you can write very readable maintainable perl. In theory. The only example of this I have ever seen is the Calcium web calendar. But whenever our perl guy writes something it looks more like
        ($l=join("",))=~s/.*\n/index($`,$&)>=$[||print$&/g e;
    (stolen from http://www.antipope.org/charlie/attic/perl/one-lin er.html) and if he has to touch it again a month later it's a dangerous thing.

  31. Re:Clarification by Anonymous Coward · · Score: 1, Informative

    That was your statement, not your argument. You stated that Perl was such, then argued is was because of an error generated by Slashdot code. That's not exactly compelling evidence of, well, anything, except maybe that the Slashdot error messages could be more verbose.

  32. My Ex-Language by tedhiltonhead · · Score: 4, Funny

    Perl is like my ex-girlfriend... I used to be all over her^H^H^Hit but am now fawning over the knockout redhead Ruby. Unfortunately, I had several children with my ex that still need to be cared for -- feature improvements, bugfixes, restarts. Hopefully one day they'll grow up and leave the house so Ruby can have me all to herself.

    1. Re:My Ex-Language by esconsult1 · · Score: 4, Interesting
      So right.

      Look over the perl 6 syntax and the increased punctuation, then compare to Ruby. I've been working with perl now for about 10 years or more, and Ruby has replaced or supplanted all my Perl work over the last several months. No going back. Not even bothering to learn Perl 6. CPAN is sweet, but so much is already built into ruby's standard libs.

      Ruby syntax is clean. Real OOP. Self documenting. No way I'm going back, especially not for Perl 6, which is too much, and too late.

    2. Re:My Ex-Language by Anonymous Coward · · Score: 0

      Man, I would love to see Perl and Ruby together. Expecially when Perl inserts a digit into Ruby to make her cumpile...

    3. Re:My Ex-Language by SanityInAnarchy · · Score: 1

      What would that even look like? I mean, well, you'd have to "make" them do it...

      Oh my fucking god. I desperately need to get out more...

      --
      Don't thank God, thank a doctor!
    4. Re:My Ex-Language by metamatic · · Score: 1

      Me three, except I've been lucky enough to be able to find the time to reimplement most of my personal collection of handy Perl scripts in Ruby.

      The replacements are about 2x slower, but I'll make that tradeoff to not have to deal with Perl syntax again.

      Perl 6 is going in entirely the wrong direction. More operators? More syntax to remember? It's turning into the C++ of scripting languages. No thanks.

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  33. Evil Perl by Michael+Woodhams · · Score: 3, Interesting

    Version 1:
    @a{($b=pop)=~/\w/g}=@a=0..9;$a="@{[keys%a]}";sub
    a{@a?map@a=(a(@_,pop@a),@a),1..@a:($_="$b
    ",eval"y,$a,@_,",/\b0/)||eval&pop}a

    Version 2:
    while($_=$a=pop){/([a-z])/i?map{($t=$a)=~s/$1/$_/g ;$a!~/$_/&&push@ARGV,"$t
    "}0..9:/\b0\d/||eval&&print}

    They do the same thing. I'll post what that is in a follow-up, for the sake of any masochists who want to figure it out for themselves.

    --
    Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    1. Re:Evil Perl by Michael+Woodhams · · Score: 4, Informative

      They are brute-force alphametics solvers. Save either into a file (say "s") then:
      $ perl s send+more==money
      9567+1085==10652
      9567+1085==10652

      If anyone can shorten either of these programs (even by one byte) please let me know. If you do, and you're geographically close enough, I'll buy you lunch. (Watch for bugs with numbers with leading zeros.)

      Version 1 is 133 bytes, version 2 is 103 bytes. Version 1 is almost entirely my own work, and contains a nifty recursive permutation generator. Version 2 was produced by someone else in response to my challenge, and then further compressed a bit by me.

      Unfortunately, the Obfuscated Perl Contest has disappeared (although these are principally compressed rather than obfuscated.)

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    2. Re:Evil Perl by Anonymous Coward · · Score: 0

      In Version 1: $_="$b" can just be shortened to $_=$b and you don't owe me lunch :)

      Mike

    3. Re:Evil Perl by Tsiangkun · · Score: 1

      quotes perserve leading zeros

    4. Re:Evil Perl by Michael+Woodhams · · Score: 1

      No, there is a newline in the string. I could have written
      $_="$b\n"
      except I used a real newline instead of \n to save a byte. (None of the newlines in either version are optional, although in one case any whitespace char would do.)

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    5. Re:Evil Perl by Michael+Woodhams · · Score: 1

      I just noticed that some /. comment preprocessing mangled a bit of version 1. Here is the correct last line with extra whitespace around &&:
      ",eval"y,$a,@_,",/\b0/)||eval && print;pop}a

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    6. Re:Evil Perl by shish · · Score: 1

      On that topic, my own hack of choice; an animated presentation engine in 341 bytes, a protest against my classmates' multi-megabyte powerpoint based presentations:

      $c=`clear`;foreach(`tail -c+341 $0|zcat`){if(/^p/){print@l;@l=()} elsif(/^d(.+)/){select$u,$u,$u,$1/10}elsif(/^s(.)/ ){$s=10;$e=-30; $m=-1;if('o'eq$1){$s=-30;$e=10;$m=1}for($i=$s;$i!= $e;$i+=$m){$j=0; foreach(@l){print substr($_,(($i+$j++)>0?($i+$j)**2:0),-1)."\n"} select($u,$u,$u,0.1);print$c}}elsif(/^c/){print$c; @l=()} else{push@l,$_}}__END__

      The full presentation with data file; a ~1:30 demonstration on floating point binary in under 2KB.

      Source with generator; have p7zip installed and run "./build.sh floating" to generate the presentation.

      I don't do much perl hackery, I'm sure someone who does could do shorter ;)

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    7. Re:Evil Perl by Anonymous Coward · · Score: 0
      I took a quick look at the second solver, here is what caught my eye:

      • the program is buggy: it appends a newline for every (distinct) character it replaces, and the output becomes very sparse. (using the -l command line switch is the best way to fix this, I moved adding the newline to the print statement, as you had not used any command line switches in your version) (+2 chars)
      • you do not need to use the slash delimiters in a !~ (or =~) match (-2 chars)
      • /(\pL)/ can be used in place of /([a-z])/i (-3 chars)
      • as the substitution matches the same letter ($1) as the original check for remainig letter, you can drop the parens in the original check and use $& instead of $1 (-2 chars)
      • the while loop only contains one statement, so you can get rid of 4 (four!) parens by moving the "while" to the end of the line (-4 chars)
      • if you do not mind not being able to solve problems of type "ABC + D = ABC", which always have multiple solutions, with D always being 0, you can drop the \d from the check for leading zeros (-2 chars)
      • there is a bizarre useless space before the semicolon in the middle, most likely added by the automagical comment mangler here. (no difference, it seems to want to add a space to my code too)


      So here's the same code with the bug fixed and 11 characters removed:
      /\pL/?map{($t=$a)=~s/$&/$_/g;$a!~$_&&push@ARGV,$t} 0..9:/\b0/||eval&&print"$_
      "while$_=$a=pop
      So, to the main point then: lunch! I live in Tampere, Finland, and in July will travel (by car) to Italy, so should you happen to live anywhere along the way, I just might drop by to take you up on your offer :-)

      Cheers,

          -bass
    8. Re:Evil Perl by Anonymous Coward · · Score: 0

      Just to clarify, the fourth bullet point in my above comment _does_ work, because when the $a!~$_ match hits (scrambling the $&), it also suppresses the pushing. From now on, the replace statement will mangle $t in unexpected ways, but it is ok, since the $a!~$_ will keep suppressing the pushing until the next /\pL/. (phew, for a second there I thought I had introduced a bug :-)

          -bass

    9. Re:Evil Perl by Michael+Woodhams · · Score: 1

      If you just want to get the byte count down at the expense of readability (as I have done) there are a few obvious tricks to apply:
      "foreach" and "for" are synonymous. (8 bytes in your example)
      for/foreach loops can sometimes be made shorter with "map" (Useful with, e.g. "1..10" which returns a list of numbers 1 to 10.)
      You can replace "\n" with quotes around a real newline (one byte)
      Don't put in any newlines anywhere except where they are used directly (as above) or whitespace is syntactically needed. (Often leads to horribly long lines) (3 bytes in your example)
      Consider the ternary conditional (condition?result1:result2) and || and && operators to replace "if" statements.
      Eliminate parenthesis around argument lists wherever possible.
      Use $_, @_ default arguments lots.
      Use multiple assignments ($a=$b=$c=0).

      One extreme action I've seen (a very compressed deCSS in Perl): where you have sufficiently repetitive bits of code (e.g. you use "print" 10 times) put your code into a string, replace the repetitive code with a single char, do a substitution and exec it. A trivial (and inefficient) example:
      $_='p"hello world\n"';s/p/print/;exec

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    10. Re:Evil Perl by Michael+Woodhams · · Score: 1

      Well done, and thank you. I acknowledge your claim for a lunch.

      I was aware of the extra newlines um, "suboptimal feature" and I appreciate the fix. (Version 1 has a different suboptimal feature: it gives each solution (10-n)! times, where n is the number of unique characters in the problem.)

      I accept the dropping of "\d" as legitimate.

      Unfortunately, Finland is a very long way from me, and your trip will take you even further. (You're getting closer to Spain, which is antipodial to me.) If you wish to persue your claim for a later date, should one of us travel half way around the world, send me e-mail. My work account name is m.d.woodhams and I work at massey.ac.nz.

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
    11. Re:Evil Perl by Anonymous Coward · · Score: 0

      Oops. After careful investigation, I realised that I actually _did_ introduce a bug, applying the fourth bullet point should break the algorithm. However, there seems to be a bug in perl 5.8.0 that exactly cancels out my bug: the $& variable seems to get properly localized only after the first match in a while (or foreach) loop. Thus the $& luckily gets reset to the previous value on each iteration, and the mangling done by !~ is canceled. This does not happen in earlier perl versions, nor in a for(;;){} loop, so it can be used only if minimal portability is desired :-)

          -bass

  34. This info needed to be published? by GatorMan · · Score: 1

    I mean really, this was worthy of a book? Couldn't these things have been covered in a linux/unix/web admin forum? Rather, *aren't* these things covered in such a way already? Am I asking too many questions?

  35. Move on, Perl is obsolete. by Anonymous Coward · · Score: 0

    Sorry, Perl is obsolite. It was useful once and it showed us the way, but it has been superceded by other
    languages like Ruby. It would be madness to start a new project in Perl now. It's time to wake up.
    CPAN was not really that useful either.

  36. Worst language for writing utilities by slabh · · Score: 1, Insightful
    Of all the popular programming languages now in use, Perl is perhaps the best suited for writing utilities -- for several reasons...

    With its awful syntax, Perl is arguably the worst language for writing any utilites. Python and Ruby are a lot better.

    1. Re:Worst language for writing utilities by mrsbrisby · · Score: 1

      With its awful syntax, Perl is arguably the worst language for writing any utilites. Python and Ruby are a lot better.

      You're right. It is arguable that it has awful syntax.

      Maybe it's that it parses and often even understands awful syntax thats bad- but I much prefer it to people that think that their code must be clean and legible and readible just because they wrote it in Python or Ruby.

  37. Perl is VB by Anonymous Coward · · Score: 2, Interesting

    I'll preface by saying that there's nothing inherently wrong with VB or with Perl. The problem occurs because both *can* foster poor programming practices. Both have an immense library of functions that allow novice scripters to hack together scripts that can perform a function. There may not be any overall design, but for lots of folks, this is more than enough. The problem occurs when you try to maintain that code (either Perl of VB) and you realize that people have pulled together modules (or ActiveX contols) that do the job, but are probably the worst or next-to-worst way of doing things. In other words, Perl and VBs downfall is their success.

    It just seems that other languages (Java, Ruby, Python) are more rigorous -- maybe because the learning curve is *slightly* higher. It's easier to write proper code in these languages because the design of the language almost enforces it.

  38. Well, by robogun · · Score: 1

    That being said let me tell you what a bitch of a time I had googling a script. I needed something to stop brute-force http password hurler attacks in realtime, all it had to do is check the log for multiple 401 errors from an ip and then ban it. My server is getting pounded (one attack - 400,000 tries in 3 hours). Googling led to hotscripts and about a jillion other script sites all referencing scripts that would do the trick - however, the authors sites were all gone by the time I looked. The only ones working were "services" to do this charging $49.99/mo and up, or selling the script at $199 or more.

    I really don't like to think that these "service" sites bought out the free authors - but it sure as hell looks like that's what happened. I refuse to support that kind of BS.

    1. Re:Well, by accessdeniednsp · · Score: 1

      tail -f /var/log/httpd/error_log | perl -e 'while () { chomp; ($ip) = $_ =~ /.*?401.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; print "Blocking $ip\n"; `/usr/sbin/iptables -A INPUT -s $ip -j DROP`; }' | tee /var/log/blocked_ips.log

      So now I wait for nitpick replies to find my bugs and tell me that I'm not using strict and warnings in a one-liner :) [oh and the ones that religiously avoid using backticks for external commands] :)

      But you get the idea.

    2. Re:Well, by accessdeniednsp · · Score: 1

      dang it!  the /. stripped out the <>  part.  grrr

      tail -f /var/log/httpd/error_log | perl -e 'while (<>) { chomp; ($ip) = $_ =~ /.*?401.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; print "Blocking $ip\n"; `/usr/sbin/iptables -A INPUT -s $ip -j DROP`; }' | tee /var/log/blocked_ips.log

      So now I wait for nitpick replies to find my bugs and tell me that I'm not using strict and warnings in a one-liner :) [oh and the ones that religiously avoid using backticks for external commands] :)

      But you get the idea.

    3. Re:Well, by Anonymous Coward · · Score: 0

      Interesting, what I have seen works by modifying htaccess, check it out. You also have to have apache make two logfiles.

      #
      $logfile = "example.com";
      $blockfile = "blocked";
      $htaccess = ".htaccess";
      $threshold = 5;
      $pointer= 8;
      #
      #print "Content-type: text/html\n\n";

      open (LOGFILE, "$logfile");
      @logfiles=<LOGFILE>;
      close LOGFILE;

      foreach $logfiles (@logfiles)  {
          (@dimensions) = split(/ /,$logfiles);
          $locatefield = @dimensions;
          $errorcode = $dimensions[$pointer];
          $attacker= $dimensions[0];
          #print "$attacker:$errorcode<br>";
          if ($errorcode eq "401"){
          $usersessions{$attacker}++;
              if ($usersessions{$attacker} > $threshold){
              &blockattacker unless ($blockattacker{$attacker});
              next;
              }
          }
      }
      sub blockattacker {
      $blockattacker{$attacker} = $attacker;
      #print "ALERT!  $usersessions{$attacker} attacks from $attacker\n";

      open (BLOCKFILE, "$blockfile");
      @banned=<BLOCKFILE>;
      close BLOCKFILE;

      open (BLOCKFILE, ">$blockfile");
          flock(BLOCKFILE, 2);
          foreach $banned(@banned)  {
              chomp $banned;
              print BLOCKFILE "$banned\n" unless ($banned eq $attacker);
              }
          print BLOCKFILE "$attacker\n" unless ($attacker eq "");
          flock(BLOCKFILE, 8);
          close (BLOCKFILE);

      open (HTACCESS, ">$htaccess");
          flock(HTACCESS, 2);
          print HTACCESS "ErrorDocument 404 http://www.superscripts.com/\n";

          print HTACCESS "AuthUserFile /dev/null\n";
          print HTACCESS "AuthGroupFile /dev/null\n";
          print HTACCESS "AuthName FUCKYOU\n";
          print HTACCESS "<Limit GET>\n";
          print HTACCESS "order allow,deny\n";
          print HTACCESS "allow from all\n";

          foreach $banned(@banned)  {
          chomp $banned;
          print HTACCESS "deny from $banned\n" unless (($banned eq $attacker) or ($banned eq ""));
          }
          print HTACCESS "deny from $attacker\n" unless ($attacker eq "");
          print HTACCESS "</Limit>\n";
          flock(HTACCESS, 8);
          close (HTACCESS);
          }

      open (LOGFILE, ">$logfile");

  39. Perl Necklace? by Col+Bat+Guano · · Score: 1, Funny

    If Perl is the glue that holds the Internet together, what does a Perl necklace hold together?

  40. C is the glue... by Fleeced · · Score: 3, Insightful

    In fact, Perl has been called the glue that holds the Internet together.

    That's not true. C was considered the glue of the Internet... Perl is the gaffa tape.

  41. As much as I hate granting time to the Perl haters by Borf · · Score: 5, Insightful

    I'm giving in this time.

    I work in a shop where we maintain (after last count) 112,002 lines of perl in a single system (which also contains about half a million lines of C).

    Guess what? It's not a problem! Not in the slightest!
    And you know why?

    - Modules
    - Coding conventions
    - Mature programmers

    Two of those three are redundant. Take a guess which ones (the third item isn't part of the anwer set).

    If you take a programmer that writes disciplined, careful, extensible, extendable and professional C - are they going to start generating hacked up crap when they switch to Perl? No. They're not. They split source among modules. They use naming conventions. They use strict. They use the namespaces. They use clear syntax. The end result looks almost like C most of the time. Except when it doesn't, 'cause it's Perl.

    What does C written by hack-job Perl "programmers" look like?

    Rephrasing #37 - "It ain't the arrow, it's the (Native American)".

  42. shame about the mod by BitterAndDrunk · · Score: 0, Offtopic

    Because I LOL now. Like Lollys.

    --
    You better watch out, there may be dogs about . . .
  43. You need a new perl guy by Wee · · Score: 2, Insightful
    But whenever our perl guy writes something it looks more like ($l=join("",))=~s/.*\n/index($`,$&)>=$[||print$&/g e; and if he has to touch it again a month later it's a dangerous thing.

    Fire your perl guy -- he's clearly a menace. And after you fire him, tell him to stop reading perlmonks.org. After a while, he'll start doing things like using foreach() instead of map() when it makes the script clearer. And as an added bonus, he won't waste time trying to find the bug he caused from overwriting $_ with a regex or whatever.

    There's no reason not to write maintainable code, perl included. That you get the choice with perl is a design goal of the language, and it's a good thing in general. But why neophytes always try to put the newest, cleverest toy they discovered into every script they write is beyond me...

    -B

    --

    Ash and Hickory, straight-grained and true, make excellent bludgeons, dandy for the cudgeling of vegetarians.

  44. Ruby's syntax *SUCKS* by mangu · · Score: 2, Interesting
    Ruby has the completely useless "end" statement they borrowed from FORTRAN77 and Ada. Stupid, stupid, stupid, how stupid can you get?


    Every text editor I know and use can match braces. Where does this block end? By clicking one or two keys I immediately know. I have no idea (and I really don't want to know) how do you match a generic "end" with the corresponding block opener in Ruby.


    Do you think this is unimportant? If so, you aren't a professional programmer, and it's OK for you to use that toy language, Ruby. But if you do coding for a living you understand how important it is to get things right with the least effort. The time you waste fighting the Ruby syntax could be used to write more code.


    Once you really learn a language like Perl or C you stop worrying about that dreaded "more than one way to do things", because you find which is your preferred way and stick to it. Once you truly understand C pointers you start to appreciate the way they let you code more efficiently the type of real-world applications that textbooks cannot present for lack of space.


    C and Perl are for professional programmers. Ruby and Python are for people who need to write short programs from time to time, better than VB, of course, but no substitute for professional quality tools.

    1. Re:Ruby's syntax *SUCKS* by Dasher42 · · Score: 2, Insightful

      C and Perl are for professional programmers. Ruby and Python are for people who need to write short programs from time to time, better than VB, of course, but no substitute for professional quality tools.

      I have to call BS on this one. I highly doubt that the parent poster has seen the ubiquitous pile of legacy Perl code lying around, and how bad and bug-ridden it can be because the programmers didn't do enough to control a sloppy language. I think Perl Medic is the only Perl book I'll ever recommend for that reason.

      Based on years of professional and hobby experience, I'd keep Perl around for 100 line one-off scripts and no more. Perl's flaws as a language have bit down hard anywhere where multiple programmers had to collaborate on a sizable project or maintain it over a period of time. The amount of nonsensical boilerplate is tremendous. Having to shovel more of it to force what is essentially an sh script with everything in the world tacked on just to keep its variables non-global is the precise opposite of what a serious language should do. And the language even lets a freestanding next or last statement in a function break loops in the calling function! Try being on a team with sloppy programmers with those kind of design flaws running loose.

      That was the past. I now work in a Silicon Valley startup where we use Java and Python, depending on the kind of work being done. Python's design scales far better for application development, with good modularization and OO done right without extra judo moves just to force behavior. The Ruby and PHP people seem pretty happy too.

      Perl was good in its day. Other languages have long since surpassed it. Let it go the way of COBOL.

    2. Re:Ruby's syntax *SUCKS* by shish · · Score: 1
      The Ruby and PHP people seem pretty happy too

      Speaking as a PHP person (one who codes it daily for a living), I'm not happy at all -- PHP is inconsistency incarnate. The built-in functions switch between using underscores or abbreviations or both or neither, argument passing order is similarly non-standard, the parser itself still surprises me, like so:

      $foo = getFoo() or die("failed to get foo");
      return $foo;

      return getFoo() or die("failed to get foo");

      These return *totally* different things. Try and guess which does what, answer below...

      (gur svefg ergheaf "sbb", gur frpbaq ergheaf "1" -- gur svefg pnfr vf vzcyvpvgyl "($sbb = trgSbb()) [ybtvpny be] qvr()"; gur frpbaq vf "erghea (trgSbb() [ovanel be] qvr())")

      I really, really wish that a scripting language that didn't suck (eg. perl, python, ruby) was as common and easy to set up as mod_php...

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    3. Re:Ruby's syntax *SUCKS* by chromatic · · Score: 1
      Try being on a team with sloppy programmers...

      I found your problem. Hint: it has absolutely nothing to do with the language you used.

      PS - don't hire crack-addicted monkeys if you care about your code.

    4. Re:Ruby's syntax *SUCKS* by arevos · · Score: 1
      Every text editor I know and use can match braces. Where does this block end? By clicking one or two keys I immediately know. I have no idea (and I really don't want to know) how do you match a generic "end" with the corresponding block opener in Ruby.

      Why would you need to? Your methods should be short enough to tell at a glance where the end is. Any class or module of sufficient length should live in their own file. This isn't C. A method in Python or Ruby that has a dozen lines is approaching the limit of acceptable length. If your methods span pages and pages, you're simply not programming very well.

      C and Perl are for professional programmers. Ruby and Python are for people who need to write short programs from time to time, better than VB, of course, but no substitute for professional quality tools.

      Frankly, you don't have the experience necessary to make such an assertion. Your uninformed opinions make you sound like an idiot. Before you criticise something, ensure you understand it well beforehand. Ignorance is rarely a good position to start an argument from.

    5. Re:Ruby's syntax *SUCKS* by sfraggle · · Score: 1
      So, Ruby is a totally useless toy language unsuitable for any professional use whatsoever because it uses "do..end" instead of "{...}"? Nice troll :-)

      Actually, one of the things I like about Ruby (and Python) *is* the fact that I don't have to waste time fighting the syntax. The most obvious example of this is the lack of ';' separators between statements. There's also the fact that there is no silly separation of variables depending on their type like there is in Perl ($var, @var, %val are all different variables in Perl).

      --
      were you expecting to see a sig here? perhaps you'd rather see the inside of an ambulance!
    6. Re:Ruby's syntax *SUCKS* by jack_csk · · Score: 1

      Agree.
      The lack of namespace and the inconsistent naming scheme is the biggest drawback for PHP to be suitable for large project. I bet most of the good PHP developers out there found those 2 issues annoying.
      As a matter of fact, I would usually build classes and put my php functions / methods under the classes.

    7. Re:Ruby's syntax *SUCKS* by Dasher42 · · Score: 1

      PS - don't hire crack-addicted monkeys if you care about your code.

      You know, you're really kinda right, but where pointy-haired bosses rule there's no guarantee. Language designers really ought to pay attention to things that cause the most common or most subtle bugs, and many of them do. If you learn C++, you learn that the reason for all those headers and namespaces is to keep code from stomping on each other, and keep things scalable. A language that read like ksh and sed and awk held together by duct tape was good for its day, but it just wasn't ready for its success without providing for these things. Perl 6 is way overdue.

    8. Re:Ruby's syntax *SUCKS* by chromatic · · Score: 1

      Sure, backwards compatibility (and in Perl 5's case, almost 12 years of growth without sufficient cleanup) makes it more difficult to come up with good coding standards, but if your team doesn't have good standards, you're in trouble no matter what the language is.

  45. Re:Clarification by mrsbrisby · · Score: 3, Insightful

    Seriously. Incomprehensible and unmaintainable code can be written in any language, but in Perl even good code is unreadable.

    It can be unreadable, but that doesn't mean that it is. Code can be good for lots of reasons- not just legibility :)

    Perl is probably the language with the highest chance of accepting the output of a random number generator as a valid program.

    That honor belongs to sendmail; We used to offhook the telephone couplers whenever someone had messed sendmail.cf up to get a good working setup from the line noise that'd leak through.

  46. It occurs to me... by Ayanami+Rei · · Score: 3, Insightful

    I've seen a lot of both.
    Really shitty, unreadable Perl that makes your head hurt. Stuff that was only designed to execute from top to bottom like a shell script and it only works in the context of some main file. Won't even run if you use sttrict.
    And beautiful, expressive object-oriented, properly packaged stuff that lets you plug and test it any which way. Stuff you aren't afraid to instrument, modify, or implement because you just understand the author's intent.

    They look almost like two different languages.

    Then again, I think this is what happen when you have languages that have a lot of built in functionality blessed with tersity and "reasonable defaults".

    You can't write spaghetti code in a more structured language like Java or C that does anything useful without code generation.

    Perl makes it possible even without syntax highlighting.
    It's _too easy_ on the programmer.

    *shrugs*

    It's like VB... except you had a web GUI with a simple "use CGI". And pervasive regular expressions (which, IMHO, is the thing that makes perl unreadable if you don't learn about the m//x modifier).
    In 1999.
    So anytime you go online searching google for a Perl script that does XYZ, you end up on one of those code-sharing sites full of "consultants" idiots and you've got the worst kind of code floating around there. Copy and pasted crap with no structure... just hacked up until it works.
    And Perl's permissiveness allows it to proliferate.

    I just write everything myself, or get it from CPAN.
    CPAN at least acts as a kind of quality control.

    If you want to see how to write or model your code, use CPAN modules as examples. You learn alot.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  47. As others are pointing out... by Ayanami+Rei · · Score: 1

    You need to use strict.
    Why?
    By default perl is lexical happy. It does what it can with what it knows.
    This is mostly in the interest of backwards compatibility and for testing stuff with "perl -ne". (You know what I mean...)
    I imagine Perl 6 will break tradition and "use strict" by default.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  48. PERL FLAME CENTRAL by Anonymous Coward · · Score: 0

    Please add your best shots here. I can't get enough of these.

    (Someone mod this up just a little so it (at least the subject) is visible.

  49. naming conventions by nephridium · · Score: 1

    "do_file()"??? - I knew geeks were desperate, but THIS desperate?

    --


    And when you gaze long enough into the code, the code will also gaze into you.
  50. Re:As much as I hate granting time to the Perl hat by mrsbrisby · · Score: 4, Funny

    What does C written by hack-job Perl "programmers" look like?

    Java.

  51. *shrugs* by Ayanami+Rei · · Score: 2, Insightful

    For the most part the POSIX C API uses NUL terminated strings, pointers to structs, and ints (and opaque types that are actually ints). Oh, and small structs made up of that stuff.
    Perl's scalar numbers internally are the same size as the system's ints, so that handles that detail.
    Perl auto-coerces strings to numbers and vice-versa. So it can handle the number and string arguments using built-in API functions that just take whatever perl expression and coerce it down to the appropriate scalar context in the glue code. Functions that wanted structs and pointers to them (say, like gettimeofday, select or localtime) would be handled at function call time -- the memory allocated only lasted as long as it was needed to issue the call and copy the return value into the result array for the caller.
    You had to actually include perl modules that defined all the constants you would otherwise get from say, stdio.h or sys/types.h since perl didn't know about them (like O_RDWR, SEEK_SET, and all that stuff). Or you could hardcode constants. :-D

    Yeah, and you'd read Perl man pages and they'd caution you how the behavior of a lot of those bare functions were OS dependant, subject to the OS's specificities (AIX, Linux, Solaris, VMS and Windows, Oh My!). I.E. Linux's select would modify the time left to wait, while Solaris's didn't specify either way (until they introduced pselect(), which didn't, and changed select() so it always did).
    Which is why the invented Perl IO and IO::Socket, and they introduced "Perl threads" -- so you could do stuff that was close to bare metal without worrying about niggling platform details.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  52. Where is Ruby's CPAN? by Anonymous Coward · · Score: 0

    CPAN is the elephant in the corner.

    1. Re:Where is Ruby's CPAN? by metamatic · · Score: 1

      RubyGems and RubyForge. Happy to help.

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  53. Re:As much as I hate granting time to the Perl hat by TwoScoopsOfPig · · Score: 1
    What does C written by hack-job Perl "programmers" look like?

    Java.
    Nah. ASP.Net. Ugliest code ever written, discounting any entries to the IOCCC.
    --
    #include <disclaimer.h>
    #include <beer.h>
  54. Not so wicked cool by Anonymous Coward · · Score: 0

    I downloaded and looked over the scripts. They're pretty simple, rudimentary instructional stuff, and don't solve much of anything. For better and more useful examples, check out Selena Sol's stuff.

  55. Get "Perl Hacks" Instead by stu42j · · Score: 1

    Most of the reviews I've read of this book have not been particularly positive. Get "Perl Hacks" instead. Or Randal's Perls of Wisdom ... Or the Cookbook ...

  56. All the Code Are Belong To Us by ramar · · Score: 1

    You can download the code (or purchase a PDF cheaper than the dead tree version) here: http://www.nostarch.com/frameset.php?startat=wcps Gotta love a published that has the balls to make the code available for free. I've got the Wicked Cool Shellscripts book, but find grep'ing the source a much handier way to recall examples.

  57. Re:As much as I hate granting time to the Perl hat by dedazo · · Score: 1

    So this is not an advantage of Perl itself, it's the result of having people who know what they're doing. Your point can be made about any project using any technology out there (which I suppose was your point =))

    --
    Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
  58. Re:Clarification by tinker_taylor · · Score: 1

    [[[It can be unreadable, but that doesn't mean that it is. Code can be good for lots of reasons- not just legibility :)]]] Incomprehensive code can at least be offset by well commented code. If you wanna show a "clever hack", at least comment it so that the next person who's looking at it will know what the magic is all about...