Slashdot Mirror


Writing CGI Applications with Perl

davorg contributes his review of Writing CGI Applications With Perl, writing "There are a very large number of Perl CGI books in the shops. Unfortunately the number of good Perl CGI books is far smaller. I'm happy to report that this book is one of them." Read on for the rest. Writing CGI Applications With Perl author Kevin Meltzer and Brent Michalski pages 500 publisher Addison Wesley, 2001 rating 9/10 reviewer Dave Cross ISBN 0-201-71014-5 summary Great Introduction To Writing CGI Programs in Perl

The problem, of course, with most Perl CGI books is that they are written by people who just don't know very much Perl. That's certainly not the case here. Both Kevin and Brent are well-respected members of the Perl community and they know what they are talking about when it comes to writing CGI programs in Perl.

Another common mistake in Perl CGI books is that the authors try to take people who know a bit of HTML and teach them programming, Perl and CGI all at the same time. The authors of this book realise that this approach is likely to lead to, at best, patchy understanding of any of these concepts so they aim there book at people who are already programmers and who have some knowledge of Perl. This means that they can concentrate of teaching the parts of Perl that are useful when writing CGI programs.

One corner that is often cut when discussing CGI programming is security. This is a very dangerous approach to take as a badly written CGI program can leave your web server open to attack from anyone on the Internet. That's not a mistake that is made here as the authors introduce security in chapter 2. Add to that the fact that the code examples all use -w, use strict and CGI.pm and the book is already head and shoulders above most of its competition.

Early chapters look at common CGI requirements such as file uploads and cookies. Each chapter is full of well written (and well-explained) sample code. The example of an access counter in chapter 6 even locks the file containing the current count - this is possibly a first in a Perl CGI book!

By the middle of the book we have already moved beyond simple CGI programming and are looking at mod_perl. This chapter covers both the "faux-CGI" Apache::Registry module and also writing complete mod_perl handlers.

In the second half of the book we start to look at some bigger examples. The authors present a web-based email system and even a shopping cart. In order to fit these examples into their respective chapters a couple of corners have been cut, but there's enough information there to enable anyone to write the complete systems.

Chapter 13 introduces the HTML::Mason module as a way to separate content from presentation. It's obvious that the author's are big fans of this module and this leads to my only real criticism of the book. At no point do they mention the fact that the same benefits can be gained from using any of half a dozen templating systems found on the CPAN. I would have been a lot happier if they had mentioned things like Text::Template, HTML::Template and the Template Toolkit before picking HTML::Mason as the system for their example.

There are then two more long chapters with examples of a document-management system and image-manipulation software. Once more, the code in these examples would serve as a great starting point for anyone wanting to implement something along these lines. The last chapter looks at XML and, in particular, the use of RSS files to provide data feeds to other web sites.

All in all this is a very useful book for someone wanting to write web-based applications using Perl. It's packed full of good advice and code that follows all of the best practices for writing CGI programs in Perl. This book won't teach you Perl, but if you've read Learning Perl or Elements of Programming with Perl then you'll find this book easy enough to follow.

You can purchase Writing CGI Applications with Perl from bn.com. Slashdot welcomes readers' book reviews -- to submit yours, read the book review guidelines, then hit the submission page.

249 comments

  1. 24 Hours by JohnHegarty · · Score: 2, Insightful

    I found sams Teach Your Self Perl in 24hour very good as a starter.... (isbn 0-672-31773-7)

    got all the basics and enough to start on cgi... evan if you don't know perl to start with...

    1. Re:24 Hours by PepsiProgrammer · · Score: 1, Troll

      Bah, php is sooo much more intuitive than cgi. cgi is dead, dead as ASP

      --
      "The United States has no right, no desire, and no intention to impose our form of government on anyone else." - Bush 05
    2. Re:24 Hours by southpolesammy · · Score: 4, Insightful

      You may be able to learn some neat things in Perl in 24 hours, but will you remember them without the book in 24 more hours?

      --
      Rule #1 -- Politics always trumps technology.
    3. Re:24 Hours by JohnHegarty · · Score: 1

      good point... still have the book on my desk two years late...

      makes a good reference though....

    4. Re:24 Hours by Anonymous Coward · · Score: 0

      What's it matter? Memory is for things that aren't written down.

    5. Re:24 Hours by sheriff_p · · Score: 3, Informative

      Your ignorance is exceeded only by your stupidity. CGI is, and I quote:
      "A set of rules that describe how a Web Server communicates with another piece of software on the same machine, and how the other piece of software (the 'CGI program') talks to the web server."
      This also makes PHP use CGI, so your comment is somewhat akin to saying "Windows is dead! Use Windows 2000!" or something equally thoughtless and banal.
      As far as concerns intuitive, what do you mean? It's easier to learn? Or do you mean you can guess at writing it? Time to find a dictionary, young Jedi.
      But, assuming you hadn't been talking utter nonsence, a quick look at jobserve, one of the biggest UK jobs sites, shows 812 ASP-related jobs, 351 Perl-related jobs, and 70 PHP-related jobs.
      So, what *exactly* are you basing your ignorant comments on?

      --
      Score:-1, Funny
    6. Re:24 Hours by PissingInTheWind · · Score: 1
      got all the basics and enough to start on cgi...

      Ok, while I agree that Perl is easy to learn, one should be carefull to call himself a programmer afther reading one of these book.

      Obviously, if you get down to programming CGI in one day, how can you know all the pitfalls you will have to avoid in order to make your CGI secure?

      So many scripts are flawed or even dangerous. Just look at the (popular) pile of crap that is Matt's Script Archive. Those CGI aren't even programmed with CGI.pm, they are badly designed, and aimed at non-programmers that will install them on their servers, not knowing much more than they have to make the script executable so it will run.

      Programming CGIs should always be done with great care, and is a task best left in the hands of professionals.

      --

      A message from the system administrator: 'I've upped my priority. Now up yours.'
    7. Re:24 Hours by Anonymous Coward · · Score: 1

      But does this book you're recommending emphasize security, using warnings and strict (etc.)? It's actually quite easy to write a little CGI script in Perl that produces more or less expected results for expected input; it's how your scripts handle failures and maliciousness that matters.

      The reviewer is spot-on in focusing on these things.

    8. Re:24 Hours by twoshortplanks · · Score: 5, Informative
      There are some good resources out there that have scripts that have been peer reviewed by many many skilled and professional Perl programmers.

      nms is such a place. It has replacements for all of Matt's scripts - and Matt himself has suggested using them as replacements for his buggy versions

      I'm sure the author of this review would agree with me that this is a good place to go to get scripts ;-)

      --
      -- Sorry, I can't think of anything funny to say here.
    9. Re:24 Hours by xanadu-xtroot.com · · Score: 0, Offtopic

      I think we need a new modifier.

      -2, Bright as a Shattered Bulb.

      or at least:

      -1, Zealot


      (and I'm a die-hard Linux user)

      --
      I'm not a prophet or a stone-age man,
      I'm just a mortal with potential of a super man.
    10. Re:24 Hours by Anonymous Coward · · Score: 0

      he probably means stand-alone programs/scripts to handle dynamic web creation are dead.

      PHP (and ASP for that matter) are html files with inlined php(/asp) code that gets executed, allowing dynamic content.

      This is much cleaner and easier to edit than having the html be generated by perl.

      I can't comment on the UK job market, but ASP and PHP are web-only (and there are 2x the ASP jobs as perl jobs, and Apache is reportedly the most popular web server). Most perl code is used for non-web/cgi purposes.

    11. Re:24 Hours by damieng · · Score: 2

      Common Gateway Interface (CGI) is a specific interface between web server and code. This interface relies on a "shelling" style system.

      PHP does not use CGI neither does ASP. By your own statement you state "A set of rules that describe how a Web Server communicates with another piece of software on the same machine..." oblivious to the fact that neither ASP, PHP or any of the modern decent languages comply with these "rules".

      Both environments utilise intstructions within the HTML code that are recognised and subsequently executed by interpreters often loaded in the web server application space.

      They DO NOT rely on environment variables, command lines and input/output files all of which are part of the CGI standard. CGI is quite rightly on it's last legs because shelling out to executables is both a security risk and processor intensive.

      Perhaps you should be more careful what you are basing your ignorant comments on.

      --
      [)amien
    12. Re:24 Hours by david+duncan+scott · · Score: 2
      Wow, arrogance and ignorance, all wrapped up into one big ball!

      Common Gateway Interface is, yes, "a set of rules that describe...", but note the indefinite article in your definition. There are, young jedi, other sets of rules as well, and PHP and ASP, among others, use those other interfaces. To continue your analogy, "Windows 2000 is a software layer between applications and hardware, and Unix is a layer between applications and hardware, so...Unix is Windows!"

      (Oh, and if you're going to quote so plonkingly, would you mind citing the quotation? If you're quoting your bother-in-law the butcher, that's a little different from quoting an RFC.)

      --

      This next song is very sad. Please clap along. -- Robin Zander

    13. Re:24 Hours by Anonymous Coward · · Score: 0

      I have to butt in here, it is by NO WAY much cleaner to have inlined php inserted in your html files. It's pure klutter.

    14. Re:24 Hours by gimpboy · · Score: 3, Insightful

      php may be more intuitive at first, but it seriously lacks alot of the functionality that comes with other languages like perl and python. while i can only speak for perl, i understand python has a similar component base. perl has cpan which makes php look like a screwdriver in a workshop full of tools. if you only plan on making a web page to take form variables and email them to someone, sure php is great. if you want to make a serious web-based application and you dont want to make everything from scratch then php is really inadiquate.

      i speak from expirence here. about a year ago i made the switch from php to perl and i haven't been happier. at the time of leaving the only database abstraction layer was in beta while perl had dbi in a quite stable form.

      while i realize the parent was probably a troll, i would strongly encourage people considering php vs (perl, python, etc.) to consider the amount of code already available outside of the base distribution of the scripting language.

      --
      -- john
    15. Re:24 Hours by clintp · · Score: 1
      But does this book you're recommending emphasize security, using warnings and strict (etc.)? It's actually quite easy to write a little CGI script in Perl that produces more or less expected results for expected input; it's how your scripts handle failures and maliciousness that matters.
      As a matter of fact it does, in a way that's entirely appropriate. Warnings are introducted as an option right away, and all of the examples use them.

      "use strict" is introduced in Chapter 8 at the same time that user-defined subroutines are instroduced, and used in all of the examples (where necessary) after that point. The most useful parts of "use strict" have to do with variable declarations (strict 'vars'). It's brought up again in the chapter on references (13) because of strict 'refs'.

      Introducing strict earlier than necessary and telling people to just "declare everything with my()" is just cargo-cult programming.

      Taintedness is brought up in the second chapter on CGI programming (the first is "Hello, World"). Again, no earlier than necessary and only when appropriate. When simple forms are introduced there's an entire section on topics like server-side checking values sent from CGI forms, encrypting form data, and so on.

      --Author of Teach Yourself Perl in 24 Hours

      PS: I really liked Kevin and Brent's book as well, enough that I volunteered to tech review it along with hoardes of others.

      --
      Get off my lawn.
    16. Re:24 Hours by gimpboy · · Score: 2


      To continue your analogy, "Windows 2000 is a software layer between applications and hardware, and Unix is a layer between applications and hardware, so...Unix is Windows!"


      actually they are both operating systems.



      The Common Gateway Interface (CGI) is a simple interface for running external programs, software or gateways under an information server in a platform-independent manner. Currently, the supported information servers are HTTP servers.


      --
      -- john
    17. Re:24 Hours by Anonymous Coward · · Score: 0

      >812 ASP-related jobs, 351 Perl-related jobs, and 70 PHP-related jobs.

      Geez, the suckier the language, the more demand there is for it.

    18. Re:24 Hours by david+duncan+scott · · Score: 2
      Yes, of course they are both operating systems! I was simply echoing sheriff_p's reasoning in a sarcastic manner. How in God's name he got a +3 informative I'll never know -- given the way he wrote that post it's hard to believe he has three friends, yet it's even harder to believe that three people (people with mod points, at that!) thought they'd learned something reading that post.

      Thank you, BTW, for citing your source. It doesn't change sheriff_p's point, since the issue wasn't so much that his definition was wrong -- it wasn't, just not as complete as he apparently thought -- but that he made such a big deal out of it ("and I quote", he says, but doesn't get around to telling us whom he's quoting)

      --

      This next song is very sad. Please clap along. -- Robin Zander

    19. Re:24 Hours by Simon+Brooke · · Score: 2
      Your ignorance is exceeded only by your stupidity. CGI is, and I quote: "A set of rules that describe how a Web Server communicates with another piece of software on the same machine, and how the other piece of software (the 'CGI program') talks to the web server."

      Brother, you seem to have a beam in your eye.

      Although it is possible to compile PHP to use the Common Gateway Interface, this is extremely rarely done (I do still have one server on which it is done, but that's because that particular server has had no software change since 1996). Almost all PHP is now run in process (as, indeed, can PERL be scripts if you use Apache's mod_perl). The Common Gateway Interface is now very rarely used in professional or production projects, although it remains appropriate for quick'n'dirty hacks.

      But, assuming you hadn't been talking utter nonsence, a quick look at jobserve, one of the biggest UK jobs sites, shows 812 ASP-related jobs, 351 Perl-related jobs, and 70 PHP-related jobs.

      ... and 2002 Java related jobs, of which the majority will be server-side. So you're comprehensively wrong on all points.

      CGI is, indeed, " A set of rules that describe how a Web Server communicates with another piece of software on the same machine, and how the other piece of software (the 'CGI program') talks to the web server." However, it isn't the only set of rules or the best set of rules, and most server-side dynamic content is now produced in-process one way or another. CGI is just too inefficient for production use.

      --
      I'm old enough to remember when discussions on Slashdot were well informed.
    20. Re:24 Hours by madprof · · Score: 1

      PHP inserted within HTML is great for small stuff. Scale that up to large sites and you have to be kidding.
      Sure, don't generate the HTML/XML from your code (as in the CGI.pm shortcut functions), but don't mix your presentation with your application logic either.

  2. I wish I'd had this book... by fatwreckfan · · Score: 0

    ...when I took my Internet Apps course last year. The book we used was more the size of a pamphlet.

  3. does the other way work by macdaddy357 · · Score: 0

    CGI apps in perl, how about perl in CGI? First post Ha.

    --
    How ya like dat?
    1. Re:does the other way work by twoshortplanks · · Score: 1

      I do not think that initilaism means what you think that initialism means.

      (apologies to the Pricess Bride)

      CGI is a interface. A Common Gateway Interface. It's a way computer programs (e.g. Perl) can be run so that their output is sent to a browser as a webpage. So yes, writing CGI Applications in Perl makes sense. The other way round does not.

      --
      -- Sorry, I can't think of anything funny to say here.
    2. Re:does the other way work by TheDick · · Score: 1

      Could you not write a CGI in PERL that then executed PHP and sent it to the browser, because I really think you could :)

      --

  4. Re:Perl is for girls by slntnsnty · · Score: 1

    Is this Flamebait? Could you possibly be serious?

  5. Reviews of Books on CGI Applications? by BlackTriangle · · Score: 0

    What, did I enter a time warp into 1995 or something? Try reviewing something relevant next time, guys.

  6. Strict by BreakWindows · · Score: 2

    It's good to finally see a CGI/Perl book pushing strict and warnings. Of course, that's not going to ensure good programming, I've seen some horribly stupid code pass the test with use strict;. Do they use Taint mode at all? Is there any mention of how dumb CGI can be, and the nasty pits it can leave when problems (not obvious to the new guy, like unchecked open filehandles) are ignored?

    Also, what's wrong with Mason? They may have recommended it because it makes an easy transition into mod_perl, as it can be used either way.

    1. Re:Strict by davorg · · Score: 1, Informative
      Do they use Taint mode at all?

      Yeah, that's covered in great depth the section on security that I mentioned in the review.

      Also, what's wrong with Mason?

      Oh, nothing. It's just that I would rather not have had it presented as the only templating solution.

    2. Re:Strict by twoshortplanks · · Score: 2, Informative
      davorg wrote:
      Do they use Taint mode at all?
      Yeah, that's covered in great depth the section on security that I mentioned in the review.
      Also, what's wrong with Mason?
      Oh, nothing. It's just that I would rather not have had it presented as the only templating solution.
      And someone marked it offtopic. How can that be offtopic? It's a direct answer to a question about the review
      --
      -- Sorry, I can't think of anything funny to say here.
    3. Re:Strict by jeffy124 · · Score: 1

      on top of that - davorg is the guy who wrote the review!

      --
      The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
    4. Re:Strict by madprof · · Score: 1

      Dave Cross is a god-send in that he is one of the main movers behind the "Not Matt's Scripts" page.

  7. Uh, what? by jabbo · · Score: 5, Insightful

    This is a little late in the game for a book that discusses ways to fork off a separate process for each hit on your dynamic pages. I'm sure the authors are studs and all, but if you're programming web applications in Perl, how about using mod_perl, and if you're going to do that, why not bite the bullet and buy Lincoln Stein and Doug Eachern's book from O'Reilly? It is a classic.

    Speaking of classics, the old "Writing Web Clients with Perl" is being superseded this month by Sean Burke's "Perl and LWP". Now speaking of Perl studs, they don't get much studlier than Sean, and LWP is (IMHO) the Killer App for Perl programmers. Another fine O'Reilly title (too bad "fine O'Reilly title" is not redundant anymore).

    Also from O'Reilly (yawn) is Rasmus Lerdorf's "Programming PHP". I was *very* pleasantly surprised by his book, it is MUCH better than it has any right to be, discussing everything from PEAR DB abstraction classes to speeding up your site with a Squid reverse cache and profiling.

    Anyways, that's just my shelf's worth. I use Perl and PHP every day (or at least every day I wear my programmer hat) to get things done fast. I know other people prefer Python and Ruby, hey, more power to them. But I figured I would point out some Fine O'Reilly Titles (note, once again, that phrase is now said more like "Honest Senator" rather than "Stupid Microsoft Security Hole") which have made me some money lately.

    YMMV...

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
    1. Re:Uh, what? by madprof · · Score: 1

      Of course mod_perl is the proper solution but not for boxes that are not dedicated to just your site. You can't run mod_perl processes with suexec obviously, so CGI is the only way forwards for secure scripting on a machine which you might share with anyone else, and that means quite a few people will still use CGI.

    2. Re:Uh, what? by gorilla · · Score: 2

      If you're writing your apps using CGI.pm, and they're ok under 'use strict', then it's very very easy to get them running under mod_perl simply by using Apache::Registry.

    3. Re:Uh, what? by Cally · · Score: 2

      This is a little late in the game for a book that discusses ways to fork off a separate process for each hit on your dynamic pages. I'm sure the authors are studs and all, but if you're programming web applications in Perl, how about using mod_perl, and if you're going to do that, why not bite the bullet and buy Lincoln Stein and Doug Eachern's book from O'Reilly? It is a classic.


      Not reading the article - bad; not reading the writeup at the top of the page before commenting -- very bad; -1 redundant post moderated up to 5: mind-blowing. Moderators, if you can't be arsed to read the article, don't moderate! Sheesh...

      --
      "None are more hopelessly enslaved than those who falsely believe they are free." -- Goethe
    4. Re:Uh, what? by jallen02 · · Score: 2

      I think people often completely miss a lot of great titles on open source topics because of O'Reilly. There have been many times where I found a topic that O'Reilly and some other press had a title published about the topic, and often the non O'Reilly titles were at least as good as the O'Reilly titles.

      I wrote a book, with a co-author, on PHP that was released about the same time Programming PHP was. Nothing against Programming PHP, it is a nice book. I read it cover to cover. It has strengths and weaknesses. But I think the book I wrote stacks up at least as well as Programming PHP, yet it is practically invisible because of the O'Reilly open source factor.

      Don't take this as me saying, "my book is the greatest thing since sliced bread",or anything like that. My book does not cover extending PHP in C, among a couple of other topics it really should have covered. But it does cover database abstraction using Pear DB. Also covered is Image manipulation, creating PDF documents, XML, almost everything a professional PHP programmer would encounter. Yet, the PHP book had very high visibility before it was even out! Anyways, don't take this post as cynical or jaded about my book not having the high visiblity etc., I wrote the book for the love of it, not for the money.

      A quick and interesting aside, Rasmus did not write a majority of the book yet he always gets the credit for Programming PHP ;).

      Jeremy

    5. Re:Uh, what? by jabbo · · Score: 3, Interesting

      In the long run, though, you'll find that Apache::Registry is not the Better Way to do it... either .pm modules with tiny bits of front-end code for the handlers, or (IMHO) PHP with the same approach (class libraries or .so extensions in C). I chose PHP after a protracted battle and some development in both. PHP is slower than mod_perl for execution, but faster than either for development (assuming you push any nasty complex code into either C, classes, or classes calling C). Even with Inline.pm, and even after 4 years of writing Perl for web apps, I've finally sworn I'll never write another line of interface code in Perl. Backend? Sure. And reading the Eagle Book is a great way to get comfortable with how Apache actually works. But I've had enough of Perl on the front end, and if you look around, so have most other people.

      Not a flame, just an observation. Apache::Registry is not a panacea.

      --
      Remember that what's inside of you doesn't matter because nobody can see it.
    6. Re:Uh, what? by gorilla · · Score: 3, Informative

      My prefered solution is actually HTML::Mason, which gives simple embedding of perl code & components into webpages. However, CGI.pm and Apache::Registery is the most portable solution, as it gives a program that can be run on both CGI & mod_perl enabled webservers.

    7. Re:Uh, what? by jabbo · · Score: 2

      A quick and interesting aside, Rasmus did not write a majority of the book yet he always gets the credit for Programming PHP ;).

      This explains a great deal of why it didn't suck. I had a sneaking suspicion that was the case.

      Bummer about your book getting spined ;-). I agree with you about the O'Reilly 'shadow'; I have a Manning title ("Data Munging with Perl") on my shelf at work that, in 2 chapters, probably made my company $50K. There is no comparable O'Reilly title worth a damn. And like I said in my post, "fine O'Reilly titles" are becoming a rare thing. But it's a lamentable reality of the current publishing environment that O'Reilly's brand recognition will carry all but the absolute weakest titles, at least for a while. They need some competition in order to bring the quality back up.

      It just doesn't sound (to me) like the reviewed book is an example of the caliber of competition needed. YMMV.

      --
      Remember that what's inside of you doesn't matter because nobody can see it.
    8. Re:Uh, what? by davorg · · Score: 1
      I have a Manning title ("Data Munging with Perl") on my shelf at work that, in 2 chapters, probably made my company $50K.

      That's very cool. I'd love to hear more details of how my book saved your comapny that much money.

    9. Re:Uh, what? by Anonymous Coward · · Score: 0

      This is a little late in the game for a book that discusses ways to fork off a separate process for each hit on your dynamic pages. I'm sure the authors are studs and all, but if you're programming web applications in Perl, how about using mod_perl, and if you're going to do that, why not bite the bullet and buy Lincoln Stein and Doug Eachern's book from O'Reilly? It is a classic.


      Why not read the review before commenting first next time?:

      By the middle of the book we have already moved beyond simple CGI programming and are looking at mod_perl. This chapter covers both the "faux-CGI" Apache::Registry module and also writing complete mod_perl handlers.
    10. Re:Uh, what? by Derleth · · Score: 1
      too bad "fine O'Reilly title" is not redundant anymore
      OK, I'll have to ask about this. I've been using O'Reilly books for years to teach me Linux and Perl (I have Using Linux, Learning Perl, Programming Perl, and the Perl Cookbook) and I've yet to find a stinker. I'll admit that my collection is tiny, but so far they're batting one thousand with me. Programming Perl, or the Camel, is ne plus ultra of Perl books, giving alphabetical listings of each and every function in the language, explaining all of them and giving examples of use. O'Relly books are written by people who know their stuff, and give both the long versions and the idiomatic versions of the code (most useful in Perl, where the idiomatic version could easily look wrong). If I ever get into Ruby or Python beyond the basic level, I plan to buy the relevant O'Reilly books. So, which O'Reilly book should I stay away from?
      --
      How can you use my intestines as a gift? -Actual Hong Kong subtitle.
  8. Who uses Perl/CGI anymore? by westmich · · Score: 0, Troll

    Who uses Perl/CGI anymore?

    1. Re:Who uses Perl/CGI anymore? by twoshortplanks · · Score: 5, Informative
      Quite a few people do. It's good for quick and simple scripts. For bigger tasks, where your server is under load, people (like, say those running this site here) use mod_perl which builds perl into the Apache server itself, giving much better performance.

      The key is that you can easily run CGI scripts - quite possibly unmodified - with mod_perl thanks to the wonders of the Apache::Registry module that ships with mod_perl. It's all covered in the guide.

      --
      -- Sorry, I can't think of anything funny to say here.
    2. Re:Who uses Perl/CGI anymore? by Jonny+Ringo · · Score: 1

      Hmmm, Who? who? oh yeah, The site you're on right now you freakin idiot.!!!!!

    3. Re:Who uses Perl/CGI anymore? by Anonymous Coward · · Score: 0

      what else would you use? vb and asp?

    4. Re:Who uses Perl/CGI anymore? by gimpboy · · Score: 2

      while i prefer perl. i believe you can get alot of the same flexability from python.

      --
      -- john
    5. Re:Who uses Perl/CGI anymore? by kperrier · · Score: 1

      Perhaps you should check this out:

      http://www.oreillynet.com/cs/weblog/view/wlg/1535

      Kent

  9. Re:Perl is for girls by JohnHegarty · · Score: 1

    Perl int he right hands will wipe the floor with any of those other languages. They may be user friendly for users of vb ... but if you can handle perl the right way you can do more in two lines than two pages of vbscript.

    It can be used with databases just as well as php or asp. I use it with interbase and find it very effierent... on a server that would never run php / asp script becuase of the requriemnts...

  10. Perl for CGI? why? by TheFlyingGoat · · Score: 1

    Although I love using Perl and am pretty good with it, I don't see why people still use Perl for CGI applications. I've grown accustomed to using PHP for all of my web apps and stick to using Perl for system administration tasks and in cron jobs that populate my databases. With languages like PHP, Python, and Ruby, why would someone still use Perl for CGI? I guess the only exception that I can think of would be if you need to make a web application on a server that you don't admin, and on which one of these other languages isn't available.

    --
    You have enemies? Good. That means you've stood up for something, sometime in your life. --Winston Churchill
    1. Re:Perl for CGI? why? by jc42 · · Score: 3, Informative

      > ... the only exception that I can think of would be if you need to make a web application on a server that you don't admin ...

      You hit the nail on the head.

      I run web sites on four machines. The one sitting in my home office is the only one where I'm the admin, and the ISP blocks port 80 on that one (not that this is a real problem, but ...).

      After experiments with PHP and Python, I've pretty much settled on perl for almost everything, with a few C programs as helpers. My perl CGI scripts run on all the machines without any changes, as do my C programs. With PHP and Python, I've found that every new machine requires a debug session to get anything to work, and I have to maintain huge sets of diffs for the different machines.

      But with perl, I can drop a new script in all my directories, and they just work. I have exactly one "per-machine" file CGI file, which lists the directories in which things are installed. Even that isn't necessary, but it's faster than the code to discover where things are.

      On one of my web sites, they still have perl 4, and my CGI scripts work fine. I can't install a current perl release, because my disk space there isn't enough to hold the unpacked perl source.

      Also, all the timing tests I've been able to run have given perl a substantial edge over everything else except C. But this is a small sample set, due to the difficulties in matching perl's capabilities in PHP (and the difficulties getting a recent Python version installed ;-).

      It would be nice to be able to depend on mod_perl, but the admins on several of these machines don't see the need for it. Even at several requests per second, my perl CGI scripts are an unmeasurable load on the machine. So why should the admins waste their time installing mod_perl for me, when it would only save a few seconds of cpu time per day?

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    2. Re:Perl for CGI? why? by Camel+Pilot · · Score: 2

      Perl combined with a good template parser and you have the best tool for developing web apps. Perl is fast, stable, powerful and ubiquitous.

      The primary mode of PHP development is to mix code within your html. This works for small or single purpose applications but sucks if you want to develop a server app that uses several different sets of templates customized for different users.

    3. Re:Perl for CGI? why? by zzyzx · · Score: 2

      Why do I write CGI with Perl? You said it yourself. "I love using Perl and am pretty good with it." If given the choice between spending my time learning a new language or spending my time writing scripts in the language I know, I'll chose the second.

    4. Re:Perl for CGI? why? by Anonymous Coward · · Score: 0

      "I love using Perl and am pretty good with it."
      Just dont try to do anything fancy.

  11. I can see why they chose Mason by madprof · · Score: 3, Insightful

    HTML::Mason is one of the most sophisticated Perl tools for templating web sites, and indeed it does a whole lot more than mere templating.
    It'd be my first choice for including in a general book as although it can get more complex (and powerful) when necessary it is actually very easy to use for simple sites.
    However yes to be fair you'd not want to ignore the very good work done by other module authors.

  12. CGI isn't used much anymore... by FortKnox · · Score: 4, Informative

    Sure, when perl was booming, CGI was all about the web, but now-a-days you find more PHP in use than perl for quick projects (or ASP for IIS users), and ColdFusion or J2EE for large web apps (I prefer J2EE with struts and taglibs, as they are cleaner).

    Hate to sound like a "*BSD is Dead" troll, but CGI is a dying breed (NOT PERL, just CGI). I'd suggest skipping this book in lew of a more popular web-app language.

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    1. Re:CGI isn't used much anymore... by twoshortplanks · · Score: 2, Insightful
      I understand your point. CGI isn't used as much as it used to be, however...

      As I said in another post, since you can run Perl CGI scripts in mod_perl (i.e. with perl built directly into Apache itself) the stuff covered in this book is still quite useful. Many powerful sites (including this one) use mod_perl, and it's a good skill to learn...starting off with CGI programming is one good way to start to go about that.

      --
      -- Sorry, I can't think of anything funny to say here.
    2. Re:CGI isn't used much anymore... by telbij · · Score: 2, Insightful

      ColdFusion for large apps? Now that's a scary thought.

    3. Re:CGI isn't used much anymore... by kisrael · · Score: 2

      Just to be a twit:
      isn't CGI the generic standard? Possibly, "Perl CGI" is less used than it used to be, (which is an interesting groundshift, one of the first non-MS developments that I'm behind the curve on--PHP seems really kludgey in parts to me, though I respect its builtin libraries) but I think just about every form in HTML points to a "Common Gateway Interface" script, you know, the thing about POSTs and GETs.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    4. Re:CGI isn't used much anymore... by orkysoft · · Score: 1
      I'd suggest skipping this book in lew of a more popular web-app language.

      CGI isn't a language.

      --

      I suffer from attention surplus disorder.
    5. Re:CGI isn't used much anymore... by tswinzig · · Score: 3, Interesting

      Sure, when perl was booming, CGI was all about the web, but now-a-days you find more PHP in use than perl for quick projects (or ASP for IIS users)

      For a while there I was giving ASP a try. But 80% of the time, I would do the little project in ASP, and then a couple weeks later I'd get a request for more and more advanced features which were either impossible in ASP, or much much more realistic in a real Perl CGI application. Inevitably I'd have to rewrite the application in Perl for any real power.

      I'll stick to Perl CGI.

      --

      "And like that ... he's gone."
    6. Re:CGI isn't used much anymore... by twoshortplanks · · Score: 1
      CGI is about running seperate programs with the arguments passed to the webserver. Things like mod_perl and (IIRC) most of the PHP and Java implementations do not run seperate programs - the webserver itself deals with the way scripts are run, or it talks to a seperate process via another socket - it doesn't start a new version of that program for each form submital.

      So no, POSTs and GETs are to do with HTTP, but they don't have to use a CGI.

      --
      -- Sorry, I can't think of anything funny to say here.
    7. Re:CGI isn't used much anymore... by reflective+recursion · · Score: 2

      People think PHP is something special. The reality is it is more like perl than not. It's truly funny watching people say perl is old and outdated for CGI use and then turn around and claim PHP is somehow better. PHP is simply an ad-hoc language just like perl. Each uses various syntax and semantics from C, Java, even BASIC (probably much closer to BASIC semantics than anything). Having two or more syntactic ways of doing a semantic process is _not_ really a good idea (code maintenance becomes more difficult).

      CGI is CGI. Perl has mod_perl, so it is on par with PHP. I'd really love to see mod_scheme. Scheme is perfect, IMO, because the ease of use and the base language, R5RS, has very useful functions which are perfect for web use. All that would be needed is an addon library to make the language a little more complete. Of course there is always mod_python, which I've heard is Lisp/Scheme-like.

      --
      Dijkstra Considered Dead
    8. Re:CGI isn't used much anymore... by Anonymous Coward · · Score: 0

      Ever given PHP a shot? It's a helluva lot like C. I'm a C/C++ programmer, and one day I decided to check into PHP. Took me a little less than 30 minutes to learn, after which I was able to write fairly advanced web apps in PHP.

    9. Re:CGI isn't used much anymore... by PythonOrRuby · · Score: 1

      Actually, as with Javascript, it's more like C++, right down to the $this.

      It's also a language that makes even quick, simple, scripts tedious. For eveything PHP has built-in, and all the overhead it brings with it, you'd think it could make common stuff like string manipulation a bit easier.

    10. Re:CGI isn't used much anymore... by PythonOrRuby · · Score: 1

      Python does borrow some functional programming concepts. However, they're of a more Haskell-ish flavor. Things like list comprehensions.

    11. Re:CGI isn't used much anymore... by PythonOrRuby · · Score: 1

      Thank you!

      A few days ago I asked a local site admin if their new system was using Perl or PHP...

      "No, we're not using CGI anymore. We moved to PHP."

      Of course, they do run everything off NT4 servers, so I really shouldn't have expected anything more.

    12. Re:CGI isn't used much anymore... by pubjames · · Score: 4, Informative

      Sure, when perl was booming, CGI was all about the web, but now-a-days you find more PHP in use than perl for quick projects [..], and ColdFusion or J2EE for large web apps[..].

      It's a shame that PHP has this reputation for only being good for 'quick and dirty' projects. I guess it is because there is so much badly hacked together PHP code available on the web. Or perhaps it's the "it can't be good - it's free" meme.

      I have come across a couple of CTOs who are put off PHP by its reputation, which is a real shame. They think it is a toy language and not suitable for large commercial projects. However, the reality is that PHP is now an extremely well designed and advanced language, and good for even very large projects. It has some extremely competent techies working on it. It is also well maintained and advancing rapidly. So, if you don't fancy PHP because of its reputation, I suggest you take another look at it.

    13. Re:CGI isn't used much anymore... by Anonymous Coward · · Score: 0

      what part of "CGI Applications With Perl" don't you undersatnd? The Perl part?

    14. Re:CGI isn't used much anymore... by kawika · · Score: 2

      ASP is pretty language-agnostic. You can use VBScript, JScript, or PerlScript to write the code in the pages. Since ASP does a lot of nice things for its hosted languages (session context, form parsing, script precompile/caching) I can't see why you'd want to go Perl CGI when you could go PerlScript ASP.

    15. Re:CGI isn't used much anymore... by Anonymous Coward · · Score: 0

      Maybe it is just because PHP IS A TOY LANGUAGE! Developers are lazy, so if they can do it quick and dirty, they sure as hell are going to do it.

    16. Re:CGI isn't used much anymore... by GutBomb · · Score: 2

      if they are using nt servers they are most likely using IIS. Perl runs through CGI on IIS. there is no mod_perl for IIS. so therefore when you ask if thier system is using perl, it makes very much sense for him to say "We're not using CGI anymore"(if they used perl before they were using CGI) We have moved to PHP (on IIS you can run PHP in 2 modes. CGI mode, (crappy) or ISAPI mode). Your thinly disguised *nixtroll failed. And so did your logic.

    17. Re:CGI isn't used much anymore... by pubjames · · Score: 2

      Maybe it is just because PHP IS A TOY LANGUAGE!

      what is your definition of a toy language?

    18. Re:CGI isn't used much anymore... by jdavidb · · Score: 2

      I can't see why you'd want to go Perl CGI when you could go PerlScript ASP.

      CPAN. Does PerlScript use CPAN? If not, the primary advantage of Perl (for me) is lost.

    19. Re:CGI isn't used much anymore... by Paul+R.E. · · Score: 1

      Amen to that.

    20. Re:CGI isn't used much anymore... by kisrael · · Score: 2

      I'm not sure if it's a "Toy", but it has a lot of attributes that seem like they're there because they made life a lot easier for the developer of thelanguage, not for the "end user developer"...especially with the variable scoping w/ functions vs. classes and all of that. (Irregularities in case sensitivty is another thing I think)

      Also, I found the error messages a lot less helpful than with some other languages.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    21. Re:CGI isn't used much anymore... by pubjames · · Score: 2

      but it has a lot of attributes that seem like they're there because they made life a lot easier for the developer of thelanguage, not for the "end user developer"

      For instance?

      I agree that the error messages are a bit obtuse at times, but that doesn't make it a toy language.

    22. Re:CGI isn't used much anymore... by CaseyB · · Score: 3, Informative
      (if they used perl before they were using CGI)

      Who's the troll?

      You can write ISAPI Perl, use Perl in ASP scripts, and create .NET components in Perl, among other options.

    23. Re:CGI isn't used much anymore... by KidSock · · Score: 3, Insightful

      Hate to sound like a "*BSD is Dead" troll, but CGI is a dying breed...

      But it will never go away entirely. For a lot of simple things CGI is quite appropriate. At work, we have a feed monitoring utility that just generates tables of timestamps. I have very rarely seen it fail. And when it does, it doesn't happen twice in a row unless there's something wrong with the database or the web server. For something mission-critical like your feed monitoring utility you don't want some stateful enterprise application amorphous cloud super server to get it's tentacles in a tangle. CGI is very easy to use, understand, and debug. Don't rule it out alltogether. It's just a tool for niche stateless applications.

    24. Re:CGI isn't used much anymore... by joeykiller · · Score: 1
      CPAN. Does PerlScript use CPAN? If not, the primary advantage of Perl (for me) is lost.
      PerlScript doesn't exactly use CPAN, but almost. Explanation follows:

      PerlScript doesn't differ much from Perl as you know it. PerlScript is just a term for "using Perl as an ASP language", not a derivation or a mutation of Perl. ActiveState's Perl distribution hooks into the Windows Scripting Host and because of this Perl can be used in ASP applications.

      As far as I remember ActiveState's Perl distribution uses something called PPM (Perl Package Manager), which is sort of the same thing as CPAN - but different in the way that it does not depend on make and gcc and other tools not available on Windows.

      What this means is that you download precompiled modules (in the cases where modules aren't pure Perl modules), not source code. This is neither better nor worse than CPAN in my opinion.

      Most of the modules in CPAN are available trough PPM.

      Actually, there's a ASP/PerlScript implementation for Apache with mod_perl that can be used on non-Windows operating systems. See www.apache-asp.org. I use it a little bit, and like it. It has a good object model.

    25. Re:CGI isn't used much anymore... by PythonOrRuby · · Score: 1

      They're actually using Apache. The server software is stable as a rock, but the server goes down every few weeks anyway.

      And it was hardly a troll. It was an expression of frustration that their most tech-savvy employees didn't understand that PHP is using the same CGI standard that their old Perl system used.

    26. Re:CGI isn't used much anymore... by Anonymous Coward · · Score: 0

      I just got offered a job (part time only) as a freelance developer for web applications in Python.

      It has to be CGI based because we don't know if it gonna be deployed on Apache, iPlanet ot whatever server they decide to use (even IIS, even when that is not probable).

      So there you go. I was actually expecting not to use CGI anymore, but it is still alive and kicking.

    27. Re:CGI isn't used much anymore... by mcjulio · · Score: 2, Informative

      PHP's lack of a requirement for variable declaration makes me consider it a toy language. I can understand providing automatic run-time variable declaration as a convenience, like strict-less Perl does, but not providing a strict option is a recipe for disaster. It's not doing me a favor to let me create bogus variables without so much as a warning.

      That and ridiculous scoping rules (having to import globals into local functions? Huh? Isn't that why I made them global to begin with?) lead me to deeply distrust it as a sturdy development platform.

    28. Re:CGI isn't used much anymore... by Anonymous Coward · · Score: 0

      Except for the fact that the semantics are the same and CGI can easily be turned into application server code on Apache with mod_perl, mod_python, mod_php etc. and competes very well with Java. For the progammer there is little difference. If you do not use Apache modules than PHP is a much CGI as perl is so I don't really know what you mean.

    29. Re:CGI isn't used much anymore... by kisrael · · Score: 2

      (if memory serves...I might be getting some of the details of function name wrong)
      For instance, the way each() and all that uses a pointer that's part of the array, and you need to call reset() on the array if you want to iterate over it twice! In general, side effects like that aren't considered a positive part of a language.

      This is kind of fixed if you use foreach() instead, and I found a bug in the docs, where it said using each() was the equivalent of foreach()...similarly, there was a bug when I was walking one array inside another array using each(), it would stop after the first outerloop. Using foreach() fixed it.

      That kind of thing is just ridiculous in a language that wants to be considered ready for primetime.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
  13. As an alternative to Perl...... by forged · · Score: 3, Informative
    I don't mean to criticize Perl, since it's my favourite language for medium to complex applications for years. You just can't beat the power of regexps :)

    Yet, I've found myself writing more and more smaller apps using PHP instead of perl. It's by the Apache group and essentially merges into the www server, making it very quick. You can still use mod_perl for perl apps.

    Along with your preferred SQL database, progranmming in PHP is a breeze. Basically, write html pages and add the commands you need embedded inside. The best PHP book I have on that topic is PHP and MySQL Web Development (ISBN: 0672317842) second to none.

    1. Re:As an alternative to Perl...... by twoshortplanks · · Score: 1
      You might want to look at some of the templating systems that are avalible. davorg mentioned The Template Toolkit in his review; This is a templating system that would allow you to use a very basic set of commands inline inside HTML to do simple looping and SQL stuff - and then to use pure Perl plugins (which you can easily write yourself) to get at the full power of Perl when you need it.

      And yes, templating systems do scale. The code that runs this site uses the Template Toolkit - there's even a section in the Slash ORA book on it.

      --
      -- Sorry, I can't think of anything funny to say here.
    2. Re:As an alternative to Perl...... by 3.5+stripes · · Score: 1

      not a nazi, but more smaller is a little redundant, smaller works fine by itself.

      --


      He tried to kill me with a forklift!
    3. Re:As an alternative to Perl...... by SoftwareJanitor · · Score: 2

      If you want a good alternative to PHP check out EmbPerl (works with mod_perl, but it is a lot easier than writing mod_perl scripts by hand), it allows you to embed Perl code into HTML similar to the way PHP works, except you've got all the power of Perl, all of the CPAN goodness to draw from, and you can much more easily mix-and-match with other Perl code (for instance back-end code like cron jobs and other stuff that most apps need).

    4. Re:As an alternative to Perl...... by nograz · · Score: 1

      > Along with your preferred SQL database,
      > progranmming in PHP is a breeze. Basically,
      > write html pages and add the commands you
      > need embedded inside.

      I'm sorry so say that, but when you think mixing markup with SQL is a good idea, then you should turn around, go home and only come back again when you've managed a Web-project >50 KLOC.

    5. Re:As an alternative to Perl...... by Anonymous Coward · · Score: 0

      PHP is NOT by the Apache group.

    6. Re:As an alternative to Perl...... by forged · · Score: 1
      • I've found myself writing more and more smaller apps using PHP

      In case that wasn't obvious in the first place, I've italicized the smaller portion for you :) I fully agree, btw. I wouldn't consider embedding SQL in html or php in html (or vice-versa) for projects > 2K lines.

    7. Re:As an alternative to Perl...... by Anonymous Coward · · Score: 0

      Check out www.php.net --> left frame --> bottom of the frame; "PHP is a project of the Apache Software Foundation. "

    8. Re:As an alternative to Perl...... by madprof · · Score: 1

      This is what HTML::Mason lets you do - embed Perl into HTML. For big projects it is very very good.

    9. Re:As an alternative to Perl...... by SoftwareJanitor · · Score: 2

      Yea, I checked out HTML::Mason before I went with EmbPerl, however, I found EmbPerl to be slightly easier, more flexible and faster. EmbPerl works well even for small and simple stuff, not just big projects.

    10. Re:As an alternative to Perl...... by szap · · Score: 1
      Heh. IMO:
      use HTML::Mason; --> BASIC
      use Template; --> Perl
      The Template Toolkit encourages the seperation of code and data ala XML/XSLT whereas Mason integrates the two (by design).

      Of course, YMMV, but do try out both HTML::Mason and Template before undertaking a large project based on either of them. Perl beginners, on the other hand, should stick to HTML::Mason for its simplicity.
    11. Re:As an alternative to Perl...... by twoshortplanks · · Score: 2
      szap wrote:
      Perl beginners, on the other hand, should stick to HTML::Mason for its simplicity.
      Of course, if you have a situation where you have an already set up machine running Template Toolkit then beginners can just use the simple templating directives that it provides. I've heard great things about people who primarly are designers getting their hands on Template Toolkit pages and quickly learning the simple templating language.

      Of course, there's more than one way to do it ;-) And more than one templating system - pick the best one for the job at hand.

      --
      -- Sorry, I can't think of anything funny to say here.
    12. Re:As an alternative to Perl...... by madprof · · Score: 1

      To be honest I doubt EmbPerl really is more flexible than Mason. I'd be interested to know what it could do that Mason couldn't.
      For small projects it might well be less overkill though.

  14. Re:Perl is for girls by Lotus1618 · · Score: 0, Offtopic

    As a "girl" I take offense to that comment. Find a creative, non-sexist way to put down a programming language next tim.

  15. Re:Holy modules by citizenkeller · · Score: 1

    Yup

    --
    -- Serge K. Keller
  16. Re:Perl is for girls by Anonymous Coward · · Score: 0

    asp and php are better for pages that are primarily static text. You can write the static html as static html, and just enclose the custom content code in tags.

    Much cleaner than

    cat

  17. I've got this book by legLess · · Score: 5, Informative
    I bought this book, and I wish I hadn't. It's not horrible, but I think there are better alternatives (like "the Mouse book" - O'Reilly's CGI Programming with Perl, which I love). These are a couple of my specific gripes with the book:
    • It looks like a nice thick book, but it's very padded. The font is huge (12 to 14 points), there's a lot of padding (most code samples listed twice, 40 pages of appendix material that could have been 8 URLs), the margins are huge, and there's an awful lot of repetition (the 10 lines justifying -wT are repeated nearly every time it's used in a program). I bet that the Mouse book squeezes twice as much content into 450 pages as this one does in 525.
    • Some chapters belong better in a Perl book ("Tied Variables").
    • Some inclusions/exclusions and focus choices are very odd. There's a very detailed chapter for Mason, but no mention of templates (literally - not even in the index).
    • Their style is very choppy. They'll present a couple lines of code, then a paragraph talking about it, repeat. It's very difficult to get a cohesive view of the program this way - it's spoon-fed to you rather than presented whole. (Undoubtedly this is why they repeat all the code at the end of each chapter, but I prefer longer chunks of unbroken code).
    In short, the book is much more vocational than educational. I think this was a conscious decision of theirs, and as such I can hardly fault it - they know their target audience better than I do. However, I've not opened this book once since I read it (cover-to-cover), while I still refer to the Mouse weekly.

    Need to hack up some code fast? This book will help. If you really want to learn CGI, to know why and how it works, to have a broader grounding in the technologies used with it, and to build a firm foundation for future self-teaching, then IMHO nothing beats the Mouse book.
    --
    This isn't as much "normalization" as it is "don't take so many drugs when you're designing tables."
    1. Re:I've got this book by onlyjoking · · Score: 1

      The Mouse book is OK once you've spent half a lifetime pencilling-in the errata from the O'Reilly site. I have never, in my book-buying life, seen so many errata for a book with such a high reputation. Many of the errata are basic coding errors, too.

  18. Perl is not maintainable... by codepunk · · Score: 0, Troll

    I have been trying to get rid of some old perl code that our marketing department contracted. I would say that it is rather well written perl code, but it is still unmaintainable due to it's ugly syntax. It is time to let perl drop away, it is no longer needed and is not a enerprise suited language.

    --


    Got Code?
    1. Re:Perl is not maintainable... by sisukapalli1 · · Score: 1


      I would say that it is rather well written perl code, but it is still unmaintainable due to it's ugly syntax.


      If you don't know perl, you probabaly shouldn't be maintaining perl code. Kinda like saying chinese script looks like a bunch of "funny pictures."

      The right tool for the job...

      S

    2. Re:Perl is not maintainable... by Anonymous Coward · · Score: 4, Insightful

      "It's time to get rid of java because of its ugly syntax".

      "It's time to get rid of japanese because of its ugly syntax".

      If you don't know the language, you shouldn't be maintaining it.

      Perl is quite elegant, and the $ # % all make sense. If you know Perl.

    3. Re:Perl is not maintainable... by Camel+Pilot · · Score: 2

      O.K. lets compare syntax. List what you consider to be hideous Perl code and contrast it to comparable code in your language of choice. Chances are the syntax is not what is making the code unmaintainable but bad design or your unfamiliarity with Perl or programming in general.

    4. Re:Perl is not maintainable... by codepunk · · Score: 1

      No the difference is that I do know perl but on the other hand I know MORE than just perl. I do not use a particular language for anything I use the one that best fits the job. Perl is great for parsing which it was designed to do. PHP and java where designed with the web and network as a core functionality of the language and thus are better at internet programming.Most Perl programmers are like most of the programmers I know. They know one single language and try to wedge it into everything they do.

      --


      Got Code?
    5. Re:Perl is not maintainable... by Anonymous Coward · · Score: 0

      You're quite right, they all make sense, if you know the language.

      But so help me, they're still kinda ugly =) [ and given that there are going to be large syntactic differences between Perl v.s 5 and 6, evidently people close to the heart of the issue agree with me ... ]

      But you'll pry my s/([^"]+).*/uc($1)/e; die unless $_ eq split(/\n/, $foo)[1] from my cold, dead hands anyway!

    6. Re:Perl is not maintainable... by cant_get_a_good_nick · · Score: 1

      that it is rather well written perl code,
      and
      but it is still unmaintainable due to it's ugly syntax.

      In my personal opinion, those two statements form an oxymoron, if it was well written, it would be maintainable. If you can't maintain it, it may be correct code, but it's not well written.

      One of Perl's biggest faults (and others would say it's strengths) is that it's probably one of the more free form languages. The syntax isn't "ugly" it is kind of an empty vessel. If you want to write your Perl resembling tight shell code, you can. If you want to write it so it resembles some product of a random dictionary generator, you can. The language doesn't enforce any style, it is up to the programmer to enforce this.

      The free form style is probably an aid in small tasks, where you just want to get things done, and are likely to throw the script away. It is a hindrance in larger projects where maintenance problems arise. To have well written Perl code requires more discipline from the programmer. Pick a style, enforce it. Don't use the cool tricks of the language as much just to show that you know them.

    7. Re:Perl is not maintainable... by Misuta+Supakulo · · Score: 2, Insightful

      I don't care how ugly $, @, etc. looks I'm damn glad Perl, PHP, and friends use special characters to dilineate variables! When you scan through code in something like C often times it's not so easy to figure out just what's what, what's a function, what's a variable, what's some gawdawful clever #define dohicky, etc. I'll take ugly and understandable over pretty and incomprehensible any day.

      --

      --
      He lied to us through song. I hate when people do that!
    8. Re:Perl is not maintainable... by Fweeky · · Score: 2
      Perl is quite elegant, and the $ # % all make sense. If you know Perl.

      I'm not sure I'd class Perl as being elegant. It's very overcomplex and convoluted to my eye.

      Simple things like creating classes, passing large data structures about, gracefully handling error situations, even handling argument lists for subroutines, all require either too much code or too many /\W/'s.

      I do admit to seeing some degree of elegance in the whole @foo[] thing, but I'm growing increasingly alergic to touching native data structures directly, so the use of syntax to denote context and type is rapidly loosing it's appeal.

      That's not to say I hate Perl, but I do find myself using Ruby for almost all the situations I'd normally use Perl. The resulting code is usually at least as concise and much cleaner. I can't say I miss it, but I don't hate it's very existance like I do VB ;)
    9. Re:Perl is not maintainable... by Anonymous Coward · · Score: 0

      The syntax isn't "ugly" it's tricky and non intuitive.
      Perl works best as a more powerfull verson of sed.

    10. Re:Perl is not maintainable... by Anonymous Coward · · Score: 0

      Large data structures are quite easy to pass around. Look into references sometime... (A reference is functionally almost identical to a C pointer, allowing similar ADT-related freedoms...)

    11. Re:Perl is not maintainable... by mcjulio · · Score: 1

      Especially in the regexp category, Perl's toolset exactly fits its problem area. Chainsaws are ugly too, but you never hear people bitch about that.

  19. Because Perl is more powerful by wackybrit · · Score: 2, Insightful

    Because Perl is more powerful and faster than PHP? Perl is a far more developed language than PHP, Python, or Ruby.

    Translating your question into client side programming speak:

    "Why use Visual C++ when you can just use Visual Basic?"

    Of course, thanks to .NET, VB.Net is as powerful as VC++.NET, but that never used to be the way ;-)

    Perl is a powerful language with far more backing than PHP, Python, or Ruby. The amount of modules you can get for Perl makes it a very wise language to use if you want to do anything advanced.. i.e. XML-RPC, SOAP, image manipulation on the fly, system integration, etc.

    PHP cannot do many of these things well.. and it cannot do them very quickly. PHP is a toy language for kiddies who are still playing with MySQL databases ;-)

    1. Re:Because Perl is more powerful by Twister002 · · Score: 2

      I don't think the argument is whether or not Perl is a better language than PHP, I think the argument is whether or not writing web apps using the CGI is better than writing web apps using PHP.

      I recently started learning Perl/CGI, just for S&Gs to use on some hobby web sites I'm thinking of developing. I realized that a lot of what I was doing in Perl w/CGI I could do just as easily, and in many cases in fewer lines, in PHP. I already knew PHP so I ended up using PHP instead of Perl.

      I think that Perl is still best used for it's original purpose, as Operating System "glue". It's great for system admin tasks, parsing through many lines of text, etc... PHP is better for rapid website development.

      PS Visual C++.NET is still more powerful than VB.NET since it allows you to use pointers and manipulate the memory directly. So the hierarchy of power in .NET, at least with the MS family of languages from most powerful to least powerful is
      VC++.NET
      C#.NET
      VB.NET

      at least from what I can tell.

      --
      "For a successful technology, honesty must take precedence over public relations for nature cannot be fooled." -Feynman
    2. Re:Because Perl is more powerful by Anonymous Coward · · Score: 0

      You forgot one language. The order should actually be:
      MSIL
      VC++.NET
      C#.NET
      VB.NET

    3. Re:Because Perl is more powerful by hey! · · Score: 2
      It's not so much what you can do with a language, it's what the language is good at.

      PHP is great when you want to quick and dirty mix code and HTML. As such is serves a purpose.
      If you try to separate content and presentation, fine, it can be done, but it's not the natural strength of the language.


      Perl's natural strength, in my opinion, is in writing routines that process textual data. PHP's natural applications are, in a sense, a subset of these, when you want to do this in the context of HTML.


      Python is not as convenient as Perl for processing data, and much less convenient than PHP for web programming, but better perhaps for generation complex systems of objects, particularly persistent ones.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  20. Writing CGI apps in PERL... by joestar · · Score: 2

    ...is the best way to eat all the memory on a server and end into a complete freeze. That's what I can see everyday on servers running different CGI apps written in Perl. On the other hand, PHP is fast and doesn't eat your memory. Of course I'll be answered that well-programmed Perl CGI apps don't eat the memory. Maybe, maybe not. The fact is I can see all those Perl CGI apps designed by more or less experienced programmers, and all those PHP apps designed by the same people. And the consequences of each ones are (very) different.

    1. Re:Writing CGI apps in PERL... by Richard5mith · · Score: 1

      I did 55,000 entirely dynamic page views (pulling stuff out of a mySQL database) with Perl one day for my messageboard system (Chatbear) when news of Valve's Steam beta test boards spread across the web. Not even full mod_perl, no caching, no fancy compile options, 128Mb and a P550 processor. All pages generated in less than a second. So Perl does the job fine. If you know how to use it. I can find you plenty of real-world examples of people who have used ColdFusion and moved away from it as it buckled under any kind of pressure, or PHP users who ended up getting bits written in Perl or C to keep the speed up. I just hate PHP-style langauges embedded in HTML I'm afraid.

    2. Re:Writing CGI apps in PERL... by god · · Score: 2, Insightful
      It's not hard to write good CGI programs in Perl if you know a little about Perl, and this book would help you do that. Let's not get into language flames. This website runs on Perl and slashcode scales pretty well indeed.

      For a bunch of secure well-written CGI programs for specific tasks, you can't beat nms. Hope this helps.

    3. Re:Writing CGI apps in PERL... by ahde · · Score: 2

      here is how php is supposed to be written:

      <?php
      require(mylib.php);
      preprocess_request($HTTP_REQUEST_VARS);
      ?>
      <html >
      <body>
      <h1>Welcome, <?php get_username(); ?> </h1>

      <h2>This is my html page!</h2>

      Here is something cool and dynamically generated:

      <?php

      /* do something cool here
      * but don't do it inline
      * call myfunction()
      * that's what require() is for
      *
      * namespaces are a bit of a problem, but you
      * can translate all the get, post, session,
      * and cookie stuff at the beginning of each
      * script -- see preprocess_request().
      */

      ?>

      <h3> I hope you enjoyed my page </h3>

      <?php include ("footer.html"); ?>

      </body>
      </html>

  21. You agree this is a smaller book? by Anonymous Coward · · Score: 0

    Can you read it with a microscope?

  22. More "expert" chapters by totallygeek · · Score: 2


    One corner that is often cut when discussing CGI programming is security. This is a very dangerous approach to take as a badly written CGI program can leave your web server open to attack from anyone on the Internet. That's not a mistake that is made here as the authors introduce security in chapter 2. Add to that the fact that the code examples all use -w, use strict and CGI.pm and the book is already head and shoulders above most of its competition.


    This is a big one for me. As a programmer, it has become increasingly difficult to compete with hackjobs out there. Anyone can pick up a book and begin writing Perl CGI or PHP websites, but not everyone has the experience to secure those systems, or to identify bad code design that leaves built-in vulnerabilities. With some companies this is hard to convey -- well, when you are proposing a $25,000 solution and there is another company willing to do it for $5,000. Nevermind that they have two programmers on their staff willing to make $20,000 this year each and they have been programming off and on for a couple of years, but they like making web pages!

    1. Re:More "expert" chapters by ahde · · Score: 2

      It sounds to me that your real complaint is that you are getting underbid by people without mortgages and car payments. Not that their code is insecure, which it usually is.

  23. Re:Microsoft confirms the truth: Perl is dying by HFXPro · · Score: 1

    You don't need to be a Kreskin to predict Perl's future. The hand writing is on the wall: Perl faces a bleak future. In fact there won't be any future at all for Perl because Perl is dying. Things are looking very bad for Perl. As many of us are already aware, Perl continues to lose market share. Red ink flows like a river of blood. ActiveState is the most endangered of them all, having lost 93% of its core developers.
    Funny, thats what my MS lovin' friends say about my programming in C++ for Windows. Know what? With all this CLR they might be right... Scarey thoughts are running through my head. Good thing I got several linux distro's ready to go. ;-)

    --
    Reserved Word.
  24. www.cgisecurity.com by Anonymous Coward · · Score: 0

    Speaking of security www.cgisecurity.com is worth a peek for those dealing with weba pplications.

  25. Re:Microsoft confirms the truth: Perl is dying by HFXPro · · Score: 1

    Sorry about everything being in italics. I was adding something near the end and deleted the HTML close for italics on accident. Post starts at Funny.

    --
    Reserved Word.
  26. You missed both of my points by jabbo · · Score: 2

    The book takes 6 chapters to get to mod_perl handlers. In that span, Stein and Eachern have already:

    1) shown you how to fit the pieces of Apache together,
    2) written sample code for 3 of the 7 standard phases of the Apache request cycle, and
    3) actually given you some insight into how to extend Apache for other purposes.

    Lincoln used to write CGI scripts. He wrote CGI.pm, in fact. Don't you think the fact that he wrote his most notable programming book on mod_perl is a telltale sign of what I find wrong with this book AND the review?

    And that witty riposte -- my god! I've never in my entire life heard that one before! Quick, somebody get Jerry Seinfeld's agent on the phone.

    I can be 'arsed' to read an article and (gasp!) form an opinion about it based on my own experience... 7 solid years of it, in this field. And looking back (with the current toolset) I would not want to see ANYONE start off re-inventing the wheel with Perl CGI scripts. Hell, if you're going to re-invent the wheel, at least make it round. CGI is, was, and will always be a kludge. Apache::Registry is a kludge to shoehorn CGI kludgers into the Better Way. Personally, I'd rather see people start out with PHP, because even if their code looks like trash, at least I can write a parser to fix it.

    End of rant.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
    1. Re:You missed both of my points by Anonymous Coward · · Score: 0
      i can't comment on whether Stein and Eachern's book is better or not... however, i've tried to use CGI.pm (written by Stein) and it's a piece of crap. i really can't understand why anybody uses it.


      to give an example, i like to write a single CGI to spew out the HTML for a form, and to process the result of the submit: this way, the variables all live in one place and can be renamed without inconsistency problems... you can't program this way with CGI.pm, both because its paradigm is broken, and because it has actual bugs.

    2. Re:You missed both of my points by CaseyB · · Score: 2
      CGI is, was, and will always be a kludge.

      What, you don't think that using shell environment variables is a natural way to access http request information?

  27. Re:Microsoft confirms the truth: Perl is dying by god · · Score: 2, Informative

    Oh my god, you're right. Perl5 has a horrible syntax, a really slow runtime, and had lots of really bad design decisions as it evolved. You know what we should do? We should start again from scratch design a new language and a really fast virtual machine. Oh wait, we already did...

  28. Liar! by Anonymous Coward · · Score: 0, Funny
    No such thing as a woman programmer. If there was, male programmers would not be addicted to pr0n and developer conventions would require male and female bathrooms instead of just one labeled, "Loser".


    Nice try at a troll there son. Just because you wear a dress and high heels doesn't make you a chick, dude.

  29. Good book, but not enough detail...not a reference by sleepy-monkey · · Score: 2, Informative

    I have this book. I found it very useful, but lacking in some ways. The authors advertised this book as not merely presenting code, but the concepts that underlay what is going on. I found this book to be primarily a bunch of recipes...just the opposite of how it was advertised. They present alot of topics and I found the breadth of this book to be very good. I do feel however, that many subjects that were addressed were incomplete. For example, in the chapter on databases, they present the SQL function calls that they need for their example, but don't even provide a list of the interface functions to write a more general application. "How about telling me how to update an existing record?". I bought this book with a little exposure to perl, and less exposure to developing websites. I found that for most topics that they presented, I needed to track down additional documentation to do anything different then what was presented in the book.

    I did find the information on mod_perl, HTML::Mason, and RSS to be especially interesting.

    If you are looking for an introduction to developing web apps with perl this book presents a large number of technologies, and does a pretty good job. It definitly is not a reference, however.

  30. Most hosts will set up PHP for you, though by jabbo · · Score: 2

    which is another huge win for that over Perl (either CGI or mod_perl). For simple web applications PHP crushes Perl (and yes, I was a Perl loyalist for 4 years, resisting the inevitable until about 2 years ago). For back-end stuff you don't need mod_perl.

    I don't see the point of CGI anymore.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
    1. Re:Most hosts will set up PHP for you, though by Anonymous Coward · · Score: 0

      For backend stuff PHP is way to insecure.

    2. Re:Most hosts will set up PHP for you, though by madprof · · Score: 1

      Sorry this makes absolutely no sense.
      You either run PHP as your own user name (suexec CGI execution of the PHP binary) or you use mod_php which is similar to mod_perl.
      I don't know how much faster PHP is to execute than Perl but Perl is fast enough for me and is more powerful. Sorry but no contest there.

  31. PHP by NitsujTPU · · Score: 1

    As much as I enjoyed writing perl CGI in my day. I find that PHP is much more suited to my current purposes and produces quicker, more readable prototypes. I mean, how am I to explain web page generation in perl to someone? Now I grab someone's pre-existing page with all of the art and stuff in tact, and add in a couple dynamically generated fields that pull data from a database.

  32. The O'Reilly Problem by wiredog · · Score: 2

    "Another fine O'Reilly title" is still often redundant. Even if not Excellent, they are often Very Good, or at least Good Enough, and I've only once encountered one (on UML, and it's long out of print) that was Mostly Useless. I trust the brand. Often I can't wait weeks to months for the reviews to come out before I buy a book. So I buy the brand I trust.

  33. mouse book by bcrowell · · Score: 2

    I agree -- the mouse book rocks! The part on CGI debugging is particularly good. Not only that but the first edition is free in digital form.

  34. RE: oooh perls just too slow etc by Anonymous Coward · · Score: 1, Insightful

    Seems to me, a few people claim that Perl is no good for writing dynamic Websites...

    Erm.... Slashdot seems to work and scale pretty well to me - thats written using Perl.

    Sure if you're using Plain old perl/cgi then fine...but have you guys never heard of mod_perl..

    PHP is good, but have you ever tried to maintain it....Anything other than simply "noddy" sites becomes a real pain in the ass....

    The idea of mixing Logic and HTML output is a big no-no IMHO

  35. Even PHP isn't much of a step up by kfsone · · Score: 2, Interesting

    I've done a lot of web development, in a variety of languages. I've been working in the ISP sector since 1993 - I wrote tools and utils for AmiTCP in-between increasing the dogearedness of my pink-cover first version camel book.

    PHP suffers from the same issues as JSP when it comes to building webapps and toys. It's also not really the most efficient system around either.

    Much as I love Perl, and have always enjoyed knocking out CGI systems - including one of the first "fansite"s which offered people free custom emails and URLs (warbirds.org), and I've had lots of fun with PHP, I have personally found Roxens built in RXML mark-up language to be one of the most efficient systems for developing web applications in terms of design, implementation and operation.

    Roxen was born "Spinner" back around, if not before. In all those years since, I've yet to find a good or compelling reason to use Apache, Perl or PHP instead of Roxen beyond the head-count factor. The Roxen developers make their money through 'value adding' their open source webserver platform, but never really tried to market themselves.

    --
    -- A change is as good as a reboot.
    1. Re:Even PHP isn't much of a step up by Anonymous Coward · · Score: 0

      >PHP suffers from the same issues as JSP when it comes to building webapps and toys. It's also not really the most efficient system around either.

      So what is? PHP SCREAMS, plus there are cachers like PHP Accelerator

  36. CGI.pm breakage by jabbo · · Score: 2

    I can't comment on your specific example without seeing the code, but at least in my past experience, it is possible (and relatively simple) to do this with CGI.pm.

    However, it's even simpler (and faster) with PHP and that's one reason why I switched. When I first started using Perl for CGI scripts I wrote my own damn CGI %ENV{$foo} de-HTTP-encoder and for the longest time I couldn't understand why CGI.pm was so bloated (truthfully, I kind of still don't). But if you only use specific methods (use CGI.pm qw (foo bar baz); ) then it works OK.

    Like I said, I switched to PHP for this and other reasons. I still use Perl on the back end, but for volatile user-interface code, it's all PHP. I think it's a maintenance trap to use Perl if you're ever likely to hand the code over to another engineer, or (worse) do something else for a few months, then come back and try to extend it.

    YMMV.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  37. Not saved, *made* by jabbo · · Score: 2

    I implemented a storefront that depends on a business partner's calendar (for video feeds). Between LWP and the XML::Parser module that I fed the massaged LWP output into (thanks to your chapter on using the module, it took me about an afternoon to write), and a transactional update facility in the Postgres backend, we've made well into the hundreds of thousands off it. With Yahoo! Store, not only would we be forking over cash for hostage each month, but the presentation options aren't sane enough that any of the networks would buy (at least not at current buy-rates).

    So, in the span of an afternoon, and over the next few months, my design + your book made us a large pile of cash. Ask someone at CNN, C-SPAN, NBC, FOX, or Bloomberg how they like the interface... ;-)

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  38. Another useful book by Shamanin · · Score: 1

    CGI Programming in C & Perl, by Thomas Boutell. I used this book for an independent study course that I taught at a University (way back in 1997). Definitely gives you a thorough understanding of what is going on in the CGI process. I found the examples, which are in both C and Perl, to be very helpful.

    --
    come on fhqwhgads
  39. I completely agree by gruntvald · · Score: 1

    I found that most of the struggles I was having with Perl were because the ORA books (and I have nearly all the perl ones) are not really that good. Some of them are, but the beginner books most definately are not. An example is the Coriolis Perl black book. You'll learn a damn sight more with that one that "learning perl" or "programming perl". Also, the Roth books are way better for Win32 perl. But that's another kettle of bananas entirely ....

  40. mod_perl books by andy@petdance.com · · Score: 3, Insightful
    buy Lincoln Stein and Doug Eachern's book from O'Reilly? It is a classic.

    A classic, and no longer the only book in the field. mod_perl Developer's Cookbook is a tremendous tome, and I use it more than the the LDS/DOUGM book. It's well worth looking at.

    It's not better than the eagle book, but if I could only buy one, that would be it.

  41. Web apps with Java - silly thought? by Hheero · · Score: 1


    I have started developing all of my server-side and web apps in Java, and think it is a fairly easy, powerful language to use. However, it seems like I read through the comments and Java seems to always be LOW on everyone's favorite language list.
    Is this because it came too late? But I would think PHP came later. Or is it because no one wants to learn another language if they already know C++ and Perl? I personally don't have much use at the moment for C++ (but see it's importance in some things over Java like game development) and only use Perl if I'm writing scripts to learn more about Unix - Just curious why Java seems so hated.

    1. Re:Web apps with Java - silly thought? by Perlguy · · Score: 1

      I know the reason I don't use Java for web apps is because Perl was designed for text manipulation, which is what you end up doing with web apps.

      --
      -- Windows security? Sure, which ONE would you like? -me
    2. Re:Web apps with Java - silly thought? by monsterzero2002 · · Score: 1

      I developed servlets for about a year, then around the time that PHP moved to version 4 I moved into that and have yet to look back. Haven't used java for anything on the web since, except some xml-rpc server stuff (until I found out how to do that in PHP too).

      Strongly typed java is just a pain for the web (IMHO) because everything on the web comes in and goes out as a string. Scripting in general just seems to make more sense for the web.

      The fact that Java is not free software rankles a bit too. I wish Sun would just have the guts to declare Java free software (and likewise to StarOffice) and then concentrate on selling hardware, which is their strength.

    3. Re:Web apps with Java - silly thought? by Wheat · · Score: 1

      Text manipulation is what your web apps do when you write them in Perl.

      I write web apps in Python/Zope all day long, and almost never do any text manipulation. It was only a couple days ago when I was porting a Perl/CGI script into Zope without refactoring it, that I needed to enable regexs on a Zope installation that I've been using for over a year.

      If you have a hammer, then everything is a nail.

    4. Re:Web apps with Java - silly thought? by the+eric+conspiracy · · Score: 2

      The fact that Java is not free software rankles a bit too

      Well, Tomcat is perfectly free.

      As far as strong typing and strings, if you aren't using a strongly typed language you are doing a tremendous amount of debugging by hand that should be handled by your compiler. Also by disregarding Java you are also throwing away a tremendous body of web related libraries and frameworks, plus support facilities like JUnit and JMeter that are part of the Apache Jakarta project.

      Finally, if you want the ultimate reason, do a job search and look at the number of Java positions vs. Perl positions.

  42. BUT ... cgi is extremely powerful. by Anonymous Coward · · Score: 0

    Let's face it, you're not going to some
    intensive number crunching in PERL PHP ASP whatever.
    You're going to CGI to a C program.

    1. Re:BUT ... cgi is extremely powerful. by GutBomb · · Score: 2

      php has better (read: more secure) ways to do calculations using outside programs outside of the cgi layer.

    2. Re:BUT ... cgi is extremely powerful. by Anonymous Coward · · Score: 0

      You're comparing to Perl? HAHAHAHAHA

    3. Re:BUT ... cgi is extremely powerful. by GutBomb · · Score: 2

      I was comparing PHP with CGI. Not PHP with perl. I call several perl scripts from within my PHP programs using exec() and passthru() which are IMHO more stable and secure than the CGI layer.

  43. Coming from an ASP background by Pinball+Wizard · · Score: 3, Interesting
    I found this book very helpful. This and MySQL and Perl for the Web were the two books I referred to most when translating a good sized ASP project into Perl. BTW the MySQL and Perl book is written by Paul Dubois, the author of MySQL(the book), and if I could choose only one of the two it would be that one.

    Both books show how to run CGI programs under a mod_perl enabled web server, using Apache::Registry. So the myth of the server forking a new process for each request is not true. CGI and Perl in this day and age can actually run rings around an ASP solution without the performance hit CGI applications are known for causing.

    I know Perl has a lot of detractors, but really you should at least give it a chance before you make up your mind about it. Perl is probably more portable than even Java, and it certainly is better for writing quick scripts and programs. You can make the code very readable if thats your goal, or you can express in one line of code what it would take other languages 5-10 lines to accomplish. Perl/CGI is the most portable way to write web apps so if you do consulting its a good way to go if you need things that will run on lots of different web servers. I've found the neatest libraries for Perl that I haven't seen in any other language - I just wrote a shopping cart that uses SQL to read and write to comma delimited text files! This made for a perfect solution for my client, and it will be easy to upgrade to a real database when he's ready.

    Oh by the way if you don't think Perl/CGI can handle heavy duty web sites, look at the slashcode sometime - unless they rewrote everything its still CGI code running under mod_perl/Apache::Registry.

    --

    No, Thursday's out. How about never - is never good for you?

    1. Re:Coming from an ASP background by horster · · Score: 1

      > Oh by the way if you don't think Perl/CGI can handle heavy duty web sites, look at the slashcode sometime

      you're kidding right?
      _never_ look at slashcode

    2. Re:Coming from an ASP background by bad-badtz-maru · · Score: 1


      memory utilization under modperl leaves a lot to be desired and really makes it almost unuseable for heavy duty web sites unless they are as simplistic as slashdot.

      maru

    3. Re:Coming from an ASP background by horster · · Score: 1

      bingo

      tomcat->java->xml->xslt->html

    4. Re:Coming from an ASP background by Pinball+Wizard · · Score: 1
      actually since krow and pudge took over they've done some great things with cleaning up and modularizing the code.


      You're comment might apply to the pre 2.0 days of slashcode, but I'm not so sure anymore.

      --

      No, Thursday's out. How about never - is never good for you?

    5. Re:Coming from an ASP background by madprof · · Score: 1

      It depends. You can let the mod_perl processes die after a certain number of runs to make sure that they don't end up taking up loads of memory (given a leak or something).
      Perl requires lots of RAM, but then so does Java. It's totally usable for heavy duty web sites unless you're struggling with just 128 megs of RAM or something.

    6. Re:Coming from an ASP background by bad-badtz-maru · · Score: 1


      I made the mistake of selecting perl as the language in which to develop a rather sizeable web based content delivery and streaming media system for use by major latin american media companies. By the time we were entrenched in the modperl-based web frontend, we discovered that 2 gigs of ram was not enough to service just 200 concurrent web connections. It's not memory leaks, per se, the processes "just grow" each request, regardless of whether or not you preload the modules into the parent. We ended up having to kill each process off after just 3 requests which really impacts performance under high request rates. I chose perl because Template Toolkit is probably the absolute best way in the universe to separate application logic from presentation markup but if I did it again I would probably use jsp.

      maru

    7. Re:Coming from an ASP background by madprof · · Score: 1

      200 concurrent connections is a large amount for one machine. Did you not think of using more boxes?
      How long did it take the machine to service one request?
      It sounds a bit like you weren't using enough hardware.

    8. Re:Coming from an ASP background by bad-badtz-maru · · Score: 1


      We had plenty of hardware, our software team was just expecting the end product to be able to deliver 300 concurrent connections within the 200 gb limitation. We expected to operate 7-10 machines at this load level. The CPU utilization was fine on twin 750 MHz boxes but with 2 gigs it was up in the swap after about 220 connections, at which point performance understandably dies. I could get 250 connections if I set the processes to die after 3 requests but then the fork overhead starts to kill the box.

      Requests were processed at 10 per second. This is where we start getting into the postgres backend's lack of scalability.

      I really feel that modperl is just a reasonably nasty hack.

      maru

    9. Re:Coming from an ASP background by madprof · · Score: 1

      Okay, fair points. Given that coding time is ultimately more expensive than more boxes, can PHP be used to separate application and display logic easily?
      One of the reasons I use HTML::Mason is because it makes it easy to structure large web sites so they're easy to maintain. Where are the mechanisms/frameworks for doing this in PHP?

  44. "Enterprise suited" by Loundry · · Score: 2

    ...and is not a enerprise suited language.

    What, pray tell, does this mean? I have heard people tell me that they thought that perl was not "enterprise ready." When I asked them what that meant I got highly-subjective and conflicting answers.

    Is the charge that perl is not "enterprise ready" just manager-speak for expressing the prejudiced opinion that perl is merely a "hacker tool"?

    --
    I don't make the rules. I just make fun of them.
  45. Good book? by Anonymous Coward · · Score: 0

    It's a good book? What, is the only text in it "Use something else, like PHP, Python, ..."?

  46. Finish this book... by pHaze · · Score: 3, Interesting

    ..and graduate to the excellent mod_perl cookbook.

    1. Re:Finish this book... by twoshortplanks · · Score: 3, Informative
      I'd recommend reading the Eagle book first as the cookbook book is just that - a cookbook, and less of an introduction to the topic.

      I'd agree that the mod_perl Developer's Cookbook is really good, and you'll have to prise it from my dead hands before I'll give up my copy.

      --
      -- Sorry, I can't think of anything funny to say here.
  47. Re:Perl is for girls by Anonymous Coward · · Score: 0

    I find the way you put "girl" in quotation marks rather disturbing.

  48. Frameworks and Perl Criticism by suavew · · Score: 3, Insightful

    I find a lot of Perl criticism is caused by the lack of a standard framework for CGI applications written in Perl. Other programming languages (PHP, ASP) provided a relatively more confined method for writing your app, whereas Perl can be a treasure chest or a pandora's box depending on your perspective.

    There are so many ways to write dynamic Web programs in Perl: embed Perl into your HTML (embperl), embed HTML into your Perl, use a templating system (HTML::Template, Mason, Template Toolkit, etc), mod_perl, and various combinations.

    In the end, I think this is a good thing. It means more choices and better adaptability for various situations. However, it can discourage new users of the language that can quickly write CGI programs in Perl, but wind up writing bad programs.

    For anyone looking for a Perl CGI framework, I highly encourage you to check out CGI::Application on CPAN. It integrates with HTML::Template, is lighweight, and makes it relatively easy to mod_perl-ify your code if you need performance boosts.

    -Will

    1. Re:Frameworks and Perl Criticism by Fastball · · Score: 3, Insightful
      I think Perl shines in a web application development environment because you can use it back-end to front-end. I'm running a mod_perl enabled Apache server with a MySQL DBMS with great success. I write my Apache modules in Perl, add a few PerlModules lines in my httpd.conf config file, and embed Perl directives in my HTML template pages with HTML::Embperl.

      One language glues together a web server and a database nicely. You could do something similar with Java using Jakarta and Tomcat if you are prefer Java. Both ways are terrific ways to expand your content delivery.

  49. Perl and CGI? by tshak · · Score: 4, Funny

    What next? A review on "Datastructures in Fortran"?

    --

    There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
  50. Agreed - PHP can be advanced by mgkimsal2 · · Score: 2

    Our own http://www.logicreate.com product is an example of a complex system which makes PHP development of large scale projects easier than you'd think, based on the tediousness of most online PHP tutorials.

    Yes this is primarily a shameless plug, but rather than just saying 'PHP is not a toy' I figured I'd give an actual example. :)

  51. OT: Perl... by Erotomek · · Score: 2, Funny

    I don't mean to criticize Perl, since it's my favourite language for medium to complex applications for years. You just can't beat the power of regexps :)

    You can call me a twisted pervert, but I just can't wait until I sit in front of my future Debian GNU/Hurd 4.0+ system to hack some insane Perl 6 code, drinking espresso and listening to The Ride of the Valkyrie of Richard Wagner...

    --

    Krótko: kady Erotomek
    W pimiennictwie ma swój domek.

  52. +1, informative by jdavidb · · Score: 2

    I didn't realize it was ActiveState Perl. That's good. PPM is pretty good, from what I hear.

  53. Taint checks and competency by mikosullivan · · Score: 1
    The first thing I do when I look at a Perl CGI application is see if it uses tainting. If it doesn't I assume the author is incompetent.

    It's amazing how emotional people get in their resistence to this wonderfully simple and handy security check. See this discussion for an example of the lengths to which people will go to avoid putting a simple T in their code.

    --
    Miko O'Sullivan
  54. coldfusion is still king by Anonymous Coward · · Score: 0

    why in the world would someone sit there and write a shopping cart or other complex dynamic driven site in Perl? Perl is so unmaintainable and unportable. I personally use CF for all of my applications. It's ALOT easier and faster to develope in then Perl. Plus with the version for Linux, it is easy to port to the other enviroment. Perl is a dead language. With all of the other better and smarter choices to choose from to develope with, why bother with Perl?

    1. Re:coldfusion is still king by runjeffrun · · Score: 1

      You must be joking. Have you ever written a large application in CF? Talk about unmaintainable and undocumentable. CF is nice for simple one-off sites, but we've found it absolutely terrible for large-scale sites to which the customer wants constant functional additions. In fact, we're currently in the process of moving from CF 5 to perl, and the switch to an environment thats both a true language and object-oriented has been wonderful ,in terms of modularity and reusability.

  55. 500 pages? by Animats · · Score: 1

    That's way too big for the subject. As someone else remarked, much of it is big margins, big type, repetition, duplicated code listings, and fluff. This whole subject should be covered in no more than 100 pages.

    1. Re:500 pages? by Perlguy · · Score: 2, Insightful

      100 pages? Sure, we could have done, but then nobody would ever *learn* from the book.

      This book was designed to be a learning tool, with practical examples.

      My goal with the writing that I did was to provide concrete examples people could use and learn from, directly. I have seen too many books that show a concept and then explain a bit about it, but NEVER really show you how to duplicate it. Instead, every line of code is explained so that the reader can see how and why it works.

      Sure, if you are comfortable with Perl and writing CGI's, this book is probably not for you...

      Also, those people saying CGI's are dead. Um, heh, ok - think what you will...

      Brent

      --
      -- Windows security? Sure, which ONE would you like? -me
  56. Muahahaaahaa by Perlguy · · Score: 2, Insightful

    For all the PHP zealots out there. Yes, I too like PHP, it has many good features.

    But, I find that if I want to do dynamic content, HTML::Mason is much better (for me at least). I can embed the Perl right into the HTML, plus Mason has a lot of other nice features that make it worthwhile.

    Plus, I am having a lot of fun reading all of the comments generated by this discussion.

    It really amazes me how people basically say things like "Well, I use X for this so everyone else should too"... The key to being a good web developer is using the right tool for the job AS WELL AS utilizing the tools available to you. you also need to take into account what you are better at. I am a Perl developer, sure, I could choose to write apps in C, Java, PHP, Ruby, whatnot, but then I am not utilizing MY talents to their fullest.

    Lots -O- flame-bait in these discussions, that is for sure...

    Brent

    --
    -- Windows security? Sure, which ONE would you like? -me
  57. Re: oooh perls just too slow etc by bofkentucky · · Score: 1

    That's why you abstract your code out, database connections in one file, html headers/footers/boilerplate in one, javascript libraries in another. Using slash as an example, users.pl, index.pl, comments.pl, and metamod.pl, all make calls to other code sources to generate page layout, database connections, and other features. Yes PHP (or SSI/Embperl or ruby, or python)can be used for "I need to generate a single table from my dbase in this monster page, I'll just throw a mysql_connect here, a echo there and I'm done", but it also can be done in a highly modular way.

    --
    09f911029d74e35bd84156c5635688c0
  58. I have to take issue with this: by morven2 · · Score: 1

    Java no more has the web and network as a core functionality of the language than perl does. They're both a function of a) the environment in which the code runs, and b) standard libraries.

    Java is just a somewhat OO C-family language, otherwise. It's the libraries that give it network and web functionality, just like perl.

    Now, it might be arguable that the java libraries and integration of the java environment into web servers is better than the perl libraries and perl integration into web servers. So make that argument!

    1. Re:I have to take issue with this: by ahde · · Score: 2

      if curly braces and semicolons make java a part of the C family, then glasses and bad haircuts make linus and bill gates brothers.

      Puctuation does not make languages similar!!!

  59. Re:badonkadonk by Anonymous Coward · · Score: 0

    This book would have been totally sweet in 1996 when 'Perl' and 'cgi' were the best solution.

    Who are you people using Perl? And why? Perl monkeys can't be trusted to make CGI's -- they're too likely to leave security holes.

  60. Ummm, no... by jabbo · · Score: 2

    mod_php transparent to the PHP code. No calls to Apache::Registry, no use strict; no difference whatsoever. Therein lies the advantage for people who are hosting with a provider. And most providers have mod_php running, or will set it up for you (pair.com for example). To run mod_perl you're looking at a dedicated server for sure.

    I have no idea what you've been doing with php, but to claim that mod_php is "like mod_perl" is one of the most ludicrous things I've recently heard. The only way mod_php is "like" mod_perl is that it's an Apache module (most of the time...).
    mod_perl is much more powerful (and dangerous).

    PHP code running under mod_php is SLOWER than a mod_perl handler. The big win comes in terms of development and maintenance (and portability).

    If you want to use Perl, please do so, but don't go implying that mod_perl's functionality is identical to mod_php. That's very misleading.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
    1. Re:Ummm, no... by madprof · · Score: 1

      Ah no I was not claiming that mod_php gave you some PHP interface to the Apache API or anything silly.
      It was, as you identified, that it embeds the technology within the web server.
      So which user runs your PHP scripts? You or the web server user?
      Who then owns files that are opened? What about putting passwords in database connection code?
      If I have a CGI Perl script I can have the database run an ident check to make sure the owner of the process running matches theowner of the table being accessed. No password needed. My files are chmodded 0700 too. Using mod_php/mod_perl I am not sure this is possible.

      If that's not correct then fair enough but it is AIUI.

  61. Pay Attention! by Anonymous Coward · · Score: 0
    This is a little late in the game for a book that discusses ways to fork off a separate process for each hit on your dynamic pages. I'm sure the authors are studs and all, but if you're programming web applications in Perl, how about using mod_perl, and if you're going to do that, why not bite the bullet and buy Lincoln Stein and Doug Eachern's book from O'Reilly? It is a classic.

    Why not read the review before commenting first next time?:


    By the middle of the book we have already moved beyond simple CGI programming and are looking at mod_perl. This chapter covers both the "faux-CGI" Apache::Registry module and also writing complete mod_perl handlers.
  62. You should take your own advice by jabbo · · Score: 2

    Read my clarification if you have a problem with what I wrote. I never claimed that the book didn't address mod_perl. I claimed that a book which focuses primarily on CGI and CGI-style applications is irrelevant. And (at least IMHO) it is.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
    1. Re:You should take your own advice by Anonymous Coward · · Score: 0


      I never claimed that the book didn't address mod_perl. I claimed that a book which focuses primarily on CGI and CGI-style applications is irrelevant.


      LOL,I should pay attention to what you didn't write?

      The book is titled CGI programming because most people still recognize dynamic web programming as CGI and it makes use of the CGI perl libs. In order for you to use mod_perl, all you have to do is install it on the webserver and make sure you write all your libs OO or export your functions and variables properly. Did you think he should write a whole book about that?

    2. Re:You should take your own advice by jabbo · · Score: 2

      In order for you to use mod_perl, all you have to do is install it on the webserver and make sure you write all your libs OO or export your functions and variables properly. Did you think he should write a whole book about that?

      Lincoln Stein did, and I think it's an awful lot better and more useful than a book that misleads people into thinking that a kludge like CGI is still a good idea. He and Doug Eachern also waste time on obsolete languages like C, which of course no one would want to use, and the Apache module API, which mod_perl is just a thin layer over.

      Can't you dipshits take advice? I make $15K a DAY when my company pimps out my custom programming skills. You think I get paid like that because I can't read? All I'm trying to do here is save other people from making mistakes I made 4 YEARS AGO since, nowadays, they're obvious.

      --
      Remember that what's inside of you doesn't matter because nobody can see it.
  63. There are better tools out there... by ralphbecket · · Score: 1

    This is going to go down like a cup of cold sick, but...

    If you do this sort of thing for a living, it would pay to look into alternative tools that make your life easier. For instance, check out the available Haskell web/CGI/HTML/XML libraries. Coding plain and interactive web interfaces that are rock solid is so much easier it's not funny. A whole raft of bug classes are simply impossible using these schemes.

    By the way, before anybody says otherwise, Haskell is a serious, full-blown industrial strength language.

  64. Perl, PHP, Python et al. by musicmaker · · Score: 1

    I am fluent in all these langauges and several others. I have written CGI/Mod scripts in all, including C/C++ and Java.

    CGI is SLOW. There is now way around it. The perl _interpreter_ just takes too long to load to take seriously on any site that has a high throughput. mod_perl has memory leak issues, and just isn't for the faint hearted.

    We don't need more books on CGI/Perl. We need more people lobying web hosts to have mod_python/PHP available.

    So many people complain that PHP lacks templatization capability. it has include(), and it has a very good, and simple to implement XML parser that allows you to generate a very powerful template system. I know because I've built one, and I work for a web application design house, that doesn't do anything much under $10k jobs. We are a pure Linux/Solaris shop.

    PHP has the best documentation in a centralised location. Perl doesn't, and neither does Python. I would much prefer to use mod_python, but documentation on python is difficult and confusing compared to PHP for junior developers.

    You can certainly do more in Perl than PHP, but Perl faster?!! *rofl* that's a good one. I have built enterprise class websites in PHP for several years, and I have never once had a major problem with it's ""Lack of features"". It does everything you need, and more. The only problem with PHP is writing non CGI/Mod scripts. For that it sucks. I use Python. Perl has a poor OO model, and it's very slow. Perl is not a peach to debug, python has exceptions which rule. Python has been shown to be as fast as C++ in several benchmarks. It's garbage collection works, unlike Java which still seems to have issues.

    One of our key products that is a very intensive search app outperforms every other company on the web today. It's written in PHP and Postgresql. Those other sites are mostly running Microsoft SQL Server with ASP, an ""Industry Standard"" on database machine four to eight times the size of ours. Please don't tell me PHP isn't mature enough, or featureful enough, thats crap. I hate the fact that it's not GPL, and I don't like it's object model, and I don't like some of the naming conventions. But it has the best documentation by far, and is the easiest to use. When you can produce a $27k website in two and a half weeks because it's that easy in PHP, what more can you say. I know Perl applications that were just so bogged down in variable issues, and namespace problems that they became unmaintainable, and lost the company they were written for real money, which could have been avoided if the project had just used a real language like Python or C++.

    Perl is a great language for hacking up a text processing thingie, or a migration script, or any one of a hundred other small things. But you can't write serious apps in it. They are unmaintainable once the primary programmer disappears because everyone has their own Perl style, it's like Stravinsky trying to finish a piece of Mozart.

    --
    Everyone is living in a personal delusion, just some are more delusional than others.
    1. Re:Perl, PHP, Python et al. by daf00masta · · Score: 1

      i completely agree with you here.... I've done some stuff with PHP, Perl, ASP (shame on me), and though Perl allowed for more powerful stuff, most of the time you dont need that much and can easily work your way around it with another language. Since I self-taught myself PHP, I was really happy with the extensive documentation, which most of the times wasn't really THAT necessary, since the language is pretty self-explanatory itself.... Also, Perl code 90% of the times is gonna be way messier than PHP or even Python code, which really fucks you over if you have to do constant changing around or things, or just maintaining the site running.... As for performance, I am no expert on that, so I'm not gonna say anything about one being faster than the other, but from what I've expereinced PHP has produced pretty damn good, satisfactory results.

    2. Re:Perl, PHP, Python et al. by johnbates · · Score: 1

      > One of our key products that is a very intensive search app outperforms every other company on the web today.

      That must have taken some time to verify.

  65. PHP and large scale projects by horza · · Score: 2
    I wouldn't say it's a toy language, but neither would I say it's suitable for large commercial projects. I use PHP for a lot of CMS stuff and there is little that can touch it for speed of development. However, I would say PHP suffers compared to J2EE in two areas:
    • Lack of persistance - in Java you can share memory-resident data between threads which means J2EE can scale considerably beyond PHP
    • Human 'resources' - Java programmers tend to come from a software engineering background, are used to working in teams, and have experience in using the tools such as CVS that are needed for larger projects.

    I agree that a lot of people underestimate PHP, which is excellent, but it is a tool for a job. imho it's for small to medium-large projects. I'm not sure I would recommend it for a seriously large project though.

    Phillip.