Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Wicked Cool Perl Scripts

samzenpus posted more than 8 years ago | from the super-awesome-programming dept.

239

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

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.

Sorry! There are no comments related to the filter you selected.

Solve it (4, Funny)

suso (153703) | more than 8 years ago | (#15623381)

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.
*/

Re:Solve it (2, Funny)

with_him (815684) | more than 8 years ago | (#15623406)

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

Re:Solve it (4, Informative)

tcopeland (32225) | more than 8 years ago | (#15623437)

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 [amazon.com] 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.

Solve it, Fixed version (2, Interesting)

fprog26 (665694) | more than 8 years ago | (#15623488)

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__

Re:Solve it, Fixed version (2, Funny)

Anonymous Coward | more than 8 years ago | (#15623526)

#!/usr/bin/python

from __future__ import solutions

solutions.solveTheWorldsProblems()

Re:Solve it, Fixed version (5, Interesting)

rgmoore (133276) | more than 8 years ago | (#15623720)

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;

Re:Solve it, Fixed version (5, Insightful)

eln (21727) | more than 8 years ago | (#15623797)

The exit statement at the end is unnecessary.

Re:Solve it (0, Troll)

QuietLagoon (813062) | more than 8 years ago | (#15623502)

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.

Re:Solve it (5, Insightful)

Anonymous Coward | more than 8 years ago | (#15623615)

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

Re:Solve it (5, Insightful)

Abcd1234 (188840) | more than 8 years ago | (#15623631)

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?

Re:Solve it (1)

funfail (970288) | more than 8 years ago | (#15623930)

You both can, and you are absolutely both wrong.

Re:Solve it (2, Interesting)

Jerf (17166) | more than 8 years ago | (#15623723)

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.)

Gaah, that was in a book? (2, Informative)

coyotecult (647958) | more than 8 years ago | (#15623571)

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

All I want to know is... (0)

Philomathie (937829) | more than 8 years ago | (#15623386)

All I want to know is... will it run Linux?

Re:All I want to know is... (4, Funny)

neonprimetime (528653) | more than 8 years ago | (#15623415)

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

Re:All I want to know is... (0)

Anonymous Coward | more than 8 years ago | (#15623435)

Good Practice? (2, Insightful)

neonprimetime (528653) | more than 8 years ago | (#15623391)

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.

Re:Good Practice? (5, Insightful)

Cleon (471197) | more than 8 years ago | (#15623404)

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

yes and no (5, Insightful)

JeanBaptiste (537955) | more than 8 years ago | (#15623410)

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.

Re:yes and no (5, Funny)

finkployd (12902) | more than 8 years ago | (#15623676)

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

Finkployd

Re:yes and no (1)

JeanBaptiste (537955) | more than 8 years ago | (#15623740)

Well yeah.

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

Re:yes and no (3, Insightful)

finkployd (12902) | more than 8 years ago | (#15623778)

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

Re:yes and no (2, Insightful)

poot_rootbeer (188613) | more than 8 years ago | (#15623831)

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.

Re:Good Practice? (3, Funny)

iamdrscience (541136) | more than 8 years ago | (#15623503)

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!!

Re:Good Practice? (5, Insightful)

drinkypoo (153816) | more than 8 years ago | (#15623616)

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.

Re:Good Practice? (1)

MindStalker (22827) | more than 8 years ago | (#15623672)

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.

Re:Good Practice? (1)

Abcd1234 (188840) | more than 8 years ago | (#15623667)

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...

Re:Good Practice? (1)

Evil Shabazz (937088) | more than 8 years ago | (#15623767)

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.

Sweet (2, Funny)

Rethcir (680121) | more than 8 years ago | (#15623397)

These scripts are wicked friggen' pissah!

Re:Sweet (0)

Anonymous Coward | more than 8 years ago | (#15623639)

Yeah, the author is wicked schmaht!

"Wicked" Cool? (4, Funny)

necro81 (917438) | more than 8 years ago | (#15623408)

The author must be from Massachusettes, possibly the Cape?

Re:"Wicked" Cool? (1)

Profane MuthaFucka (574406) | more than 8 years ago | (#15623501)

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

Re:"Wicked" Cool? (1)

misleb (129952) | more than 8 years ago | (#15623553)

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

Re:"Wicked" Cool? (1)

VJ42 (860241) | more than 8 years ago | (#15623617)

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

Re:"Wicked" Cool? (1)

takeya (825259) | more than 8 years ago | (#15623599)

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!

Re:"Wicked" Cool? (1)

PCM2 (4486) | more than 8 years ago | (#15623847)

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

Re:"Wicked" Cool? (4, Funny)

navyjeff (900138) | more than 8 years ago | (#15623883)

To our readers on the West Coast:

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

Thank you for your cooperation.

Perl glue (3, Funny)

Anonymous Coward | more than 8 years ago | (#15623418)

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?

Re:Perl glue (1)

Dutchmaan (442553) | more than 8 years ago | (#15623589)

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

That would be "pearl"

Re:Perl glue (0)

Anonymous Coward | more than 8 years ago | (#15623592)

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

Re:Perl glue (2, Funny)

tool462 (677306) | more than 8 years ago | (#15623605)

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

Re:Perl glue (0)

Anonymous Coward | more than 8 years ago | (#15623830)

So they get the name from the color?

One of my favorites... (1)

jizziknight (976750) | more than 8 years ago | (#15623422)

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

Re:One of my favorites... (1)

ajs318 (655362) | more than 8 years ago | (#15623525)

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.

I'm not impressed (3, Insightful)

cerelib (903469) | more than 8 years ago | (#15623739)

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 [google.com] ?

Yes... (-1, Troll)

Anonymous Coward | more than 8 years ago | (#15623430)

Yes, thanks, this is Slashdot. We know all about Perl and how uberly awesome it is and blah blah blah. Tag this one up to a slow news day I guess.

Re:Yes... (1)

Vorondil28 (864578) | more than 8 years ago | (#15623636)

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...

Future wickedness (4, Informative)

smitty_one_each (243267) | more than 8 years ago | (#15623449)

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 [blogs.com]
The slide show links show some terrifying code snippets.
These Perl-merlins are wicked, indeed.

Now that is a cool poll (1)

WebHostingGuy (825421) | more than 8 years ago | (#15623516)

Which will arrive first?

Vista

or

Perl 6

The race is on...

Re:Now that is a cool poll (1, Funny)

smitty_one_each (243267) | more than 8 years ago | (#15623542)

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

Re:Future wickedness (0)

Anonymous Coward | more than 8 years ago | (#15623818)

> 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.

Overhyped (0, Redundant)

Anonymous Coward | more than 8 years ago | (#15623455)

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')

Re:Overhyped (2, Interesting)

maximthemagnificent (847709) | more than 8 years ago | (#15623582)

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.

Let the religious flamefest begin! (3, Funny)

mmell (832646) | more than 8 years ago | (#15623457)

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 . . .

Re:Let the religious flamefest begin! (1)

eln (21727) | more than 8 years ago | (#15623528)

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.

Re:Let the religious flamefest begin! (4, Funny)

Bromskloss (750445) | more than 8 years ago | (#15623544)

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.

Re:Let the religious flamefest begin! (1)

Amouth (879122) | more than 8 years ago | (#15623567)

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

Re:Let the religious flamefest begin! (1)

HardCase (14757) | more than 8 years ago | (#15623614)

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?

Re:Let the religious flamefest begin! (2, Funny)

richdun (672214) | more than 8 years ago | (#15623632)

Ruby - Really User-friendly Buzzword Yeah!

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

Re:Let the religious flamefest begin! (1, Insightful)

Anonymous Coward | more than 8 years ago | (#15623840)

Python - Put Your Tin Hats ON!

Re:Let the religious flamefest begin! (1)

MrAnnoyanceToYou (654053) | more than 8 years ago | (#15623829)

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

Perl? Bah! (5, Funny)

Anonymous Coward | more than 8 years ago | (#15623471)

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.

Re:Perl? Bah! (0)

Anonymous Coward | more than 8 years ago | (#15623688)

Buzzword Bingo!
You WIN!!!!!

Re:Perl? Bah! (2, Funny)

richdun (672214) | more than 8 years ago | (#15623692)

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

Well done.

Is this more useful (4, Insightful)

stratjakt (596332) | more than 8 years ago | (#15623475)

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.

Re:Is this more useful (0)

Anonymous Coward | more than 8 years ago | (#15623675)

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

Re:Is this more useful (3, Interesting)

Tankko (911999) | more than 8 years ago | (#15623873)

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.

Clarification (-1, Flamebait)

Anonymous Coward | more than 8 years ago | (#15623476)

"Of all the popular programming languages now in use, Perl is perhaps the best suited for writing utilities" that are incomprehensible and unmaintainable. For example when I just tried to submit this comment, I got the message:

Invalid form key: 4N7tnJgHfR

Chances are, you're behind a firewall or proxy, or clicked the Back button to accidentally reuse a form. Please try again. If the problem persists, and all other options have been tried, contact the site administrator.

Re:Clarification (-1, Troll)

Anonymous Coward | more than 8 years ago | (#15623705)

incomprehensible and unmaintainable

Seriously. Incomprehensible and unmaintainable code can be written in any language, but in Perl even good code is unreadable. Perl is probably the language with the highest chance of accepting the output of a random number generator as a valid program.

Re:Clarification (3, Interesting)

Vorondil28 (864578) | more than 8 years ago | (#15623725)

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>

Re:Clarification (0)

Anonymous Coward | more than 8 years ago | (#15623770)

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

Re:Clarification (1, Informative)

Anonymous Coward | more than 8 years ago | (#15623825)

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.

OB Ruby fanboyism (2, Informative)

Teach (29386) | more than 8 years ago | (#15623489)

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.

Re:OB Ruby fanboyism (2, Insightful)

Billosaur (927319) | more than 8 years ago | (#15623647)

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.

Re:OB Ruby fanboyism (1)

Abcd1234 (188840) | more than 8 years ago | (#15623747)

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.

Re:OB Ruby fanboyism (4, Insightful)

nuzak (959558) | more than 8 years ago | (#15623867)

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.

Re:OB Ruby fanboyism (1, Informative)

Anonymous Coward | more than 8 years ago | (#15623764)

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 [rubygems.org]

Re:OB Ruby fanboyism (0)

Anonymous Coward | more than 8 years ago | (#15623822)

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.

Re:OB Ruby fanboyism (0)

Anonymous Coward | more than 8 years ago | (#15623868)

Perl has both closures and objects.

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

Fine, but about the title... (2, Insightful)

danelav (906834) | more than 8 years ago | (#15623509)

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

Re:Fine, but about the title... (1)

misleb (129952) | more than 8 years ago | (#15623623)

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

-matthew

Space = Money (1)

Mick Ohrberg (744441) | more than 8 years ago | (#15623536)

...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?

Wicked? (-1, Troll)

Anonymous Coward | more than 8 years ago | (#15623538)

Whoa, those scripts are wicked pissah!

Wicked Cool Series... (0)

Anonymous Coward | more than 8 years ago | (#15623554)

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 [amazon.com]

the relationship between Perl and C (2, Informative)

kisrael (134664) | more than 8 years ago | (#15623622)

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.

firsbt (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#15623630)

This is fucking boring (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#15623640)

Instead, let us imagine how much a better place this world would be if the armies of Bradley and Patton would have joined forces with the remaining Wehrmacht and SS divisions against the Bolshevik hordes. No Soviet Union, no Communism, but a healthy world economy from the mid 40s. Imagine how much richer, peaceful and technologically advanced we'd as a human kind be today.

Re:This is fucking boring (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#15623738)

It would also mean that we would not have GNAA. Mod the parent up!

Re:This is fucking boring (-1, Troll)

Anonymous Coward | more than 8 years ago | (#15623929)

No communism == no open source movement. Man, i liked the idea. It would save the world of so much crap...

Gnah (-1, Troll)

Anonymous Coward | more than 8 years ago | (#15623649)

Perl sucks. ASP.NET is incomparably better!

Perl praise and beefs interspersed (5, Insightful)

tinker_taylor (618697) | more than 8 years ago | (#15623704)

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.

Wicked Cool is Passé... (1)

JoshDM (741866) | more than 8 years ago | (#15623714)

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

NOT Worth While (2, Informative)

Anonymous Coward | more than 8 years ago | (#15623776)

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.

Write yes, read not so much (3, Interesting)

Sarusa (104047) | more than 8 years ago | (#15623816)

'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 [antipope.org] ) and if he has to touch it again a month later it's a dangerous thing.

My Ex-Language (4, Funny)

tedhiltonhead (654502) | more than 8 years ago | (#15623832)

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.

Evil Perl (3, Interesting)

Michael Woodhams (112247) | more than 8 years ago | (#15623859)

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.

Re:Evil Perl (4, Informative)

Michael Woodhams (112247) | more than 8 years ago | (#15623908)

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.)

This info needed to be published? (1)

GatorMan (70959) | more than 8 years ago | (#15623901)

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?

Move on, Perl is obsolete. (0)

Anonymous Coward | more than 8 years ago | (#15623909)

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.

Worst language for writing utilities (1, Insightful)

slabh (878052) | more than 8 years ago | (#15623911)

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.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?