Slashdot Mirror


Randal Schwartz's Perls of Wisdom

r3lody (Raymond Lodato) writes "Anyone who has been working on the *nix platform has had a brush with Perl, the scripting language whose acronym (depending on who you ask) could mean Practical Extraction and Report Language, or Pathologically Eclectic Rubbish Lister. In either case, there is a distinct difference between learning to use Perl, and learning to use it well. In my opinion, the best way to learn any language well is to see how others have used it to solve problems. One of the foremost experts in the use of Perl, Randal L. Schwartz, has been writing columns since March of 1995 on the use of Perl in the real world, and has provided us with 6 books and over 200 columns with many examples on how Perl is used." Read on for the rest of Lodato's review. Randal Schwartz's Perls of Wisdom author Randal L. Schwartz pages 350 publisher Apress rating 7/10 reviewer Raymond Lodato (rlodato AT yahoo DOT com) ISBN 1590593235 summary A dated compendium of the best of Randal's Perl columns

Perls of Wisdom is a collection of 65 selected columns from Linux Magazine, Unix Review, and the now-defunct Web Techniques magazines, written between May 1995 and July 2004. In each column, Randal discusses some problem that he had to solve, or that someone else needed help in solving. He carefully discusses the problem, and then shows the Perl code needed to resolve it. Many of the columns are complete applications that can be run (with minor modifications) by the reader. (The listings are also available from the apress.com web site.) Each column has been reproduced as it was written in the original magazine, with "Randal's Note" prepended. Therein lies this book's best feature and greatest flaw. Allow me to explain.

When I first picked up this book, I had only read a couple of Randal's columns (from Web Techniques), and saw that he wrote tutorials of proper Perl usage. He also relies on the wealth of modules submitted to CPAN to leverage a solution. After all, why reinvent the wheel? I expected to see more commentary on the reasons behind choosing one solution over another, or insights into the inner workings of Perl itself. I more or less got what I expected. For example, the first column reproduced in the book (It's All About Context) explains why, when someone used my ($f) = 'fortune'; instead of my $f = 'fortune'; he got in trouble with the law (see the book to understand the legal issue). The first form only retrieves the first line of the output of the fortune program, while the second form retrieves the entire output. Little items such as scalar versus list context can trip many Perl coders.

The first chapter (Advanced Perl Techniques) does give you many tips and insights like the example I just gave. All but two of the twenty columns are little tutorials on the ins and outs of handling the commonplace day-to-day issues that Perl can address with ease. Some delve into more obscure topics, such as the difference between shallow and deep copies of structures, and Perl's Taint mode. Two columns contain complete programs. One extracts the text from the man pages and determines their "fog" index (a measure of readability). The other creates a mirror of files needed by CPAN.pm to install new modules. For each program, Randal gives the entire listing as well as an almost line-by-line description of how it works. Each column is written in a conversational style that is easy to read, yet doesn't talk down to you.

The following chapter is comprised of seven tutorials on the various aspects of searching, sorting, and formatting text. In addition to describing the creation and compilation of regular expressions, Randal also discusses formatting and the nifty "Schwartzian Transform" (Perl's map-sort-map idiom for sorting on almost anything) which was named for him, but not by him. While some of the information is a little long-in-the-tooth (the column on Text-Processing was written shortly after Perl 5 was released), it's all interesting and educational nonetheless.

Chapter 3 starts refocusing the use of Perl to web sites. This chapter discusses HTML and XML processing in six little columns. He shows how to generate a web page index, producing a web page calendar from a file of events, and parsing XML to retrieve the data within. He also includes a lesson on how to use Perl to compare two arrays to create an HTML-formatted difference table.

The next chapter demonstrates that Randal has spent a lot of time working out ways to update and improve his web site. It covers the intricacies of CGI programming in Perl. All but one of the fifteen columns are complete programs (again, available from apress.com) with line-by-line commentary. The programs do implement mostly worthwhile functionality, but each column was pretty much "I had this problem, so I wrote this program. Lines 1-3 do this; lines 4-5 do that, etc." Granted, some of the programs are pretty nifty (check out how he automatically keeps track of the "What's New?" pages), but the reading of one program after another started to become stale.

The final chapter is titled "The Webmaster's Toolkit," consisting of fourteen programs and three tutorials. Randal covers diverse web server background topics such as creating a light-weight load balancer, random links, and forcing users to enter through the "front door." There are also instructive techniques for throttling your web server's usage of the processor (a necessity at the time for Randal, as his web site was co-resident on a server with others), and calculating download times.

In its entirety, Perls of Wisdom contains 65 columns, split roughly half-and-half between tutorials and fully commented programs. More than half of the columns show that Randal uses Perl for web processing more than for general scripting, data reduction and reporting. His tutorial articles are top-notch, but I have a quibble over his program articles, which are somewhat dated. There were a number of prefaced notes to the effect that today he'd do it differently with some new feature or CPAN module. I really wish he had actually updated the column to show the new coding techniques. The original code is interesting in the historical sense, but I wanted to see nuggets of Perl wisdom for me to use in my daily job. The writing style is fine; the bits of insight are useful, but many of the programs are too specific to problems you or I may never see, and were solved in code that's showing its age. I'm glad I got to read the book, but I think it only rates a 7 out of 10.

You can purchase Randal Schwartz's Perls of Wisdom from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

282 comments

  1. Wow by Anonymous Coward · · Score: 0

    Randal Schwartz totally change everything about perl. I mean, the things people can do now. My mind = BLOWN by his contributions.

  2. CGI programs by JaxWeb · · Score: 5, Informative

    I first learn Perl with the aim of creating dynamics webpages. I learnt from the tutorial Picking Up Perl - this is great and taught my most I needed to know with regard to the language - but it didn't teach me how to use it for websites.

    I picked up from code lying about how to read and write files, get post/get data, and so forth, and slowly built up into quite a good Perl programmer (I suppose. Not amazing, but quite fluent). This wasn't easy though and was slow. Why? I never got taught, all in one place, how to do that. I think this is what this book is trying to do - but with a much wider range than just CGI programs (although it doesn't seem to neglect it, either).

    I tried to write my own tutorial for using Perl in webpages to try and help. I'm not going to link to it here though, because it is quite terrible (I was 14 when I wrote it).

    After learning Perl, and being able to use it, there is always using the standard librarys. For this, PerlDoc has been so helpful to me.

    --
    - Jax
    1. Re:CGI programs by stu42j · · Score: 2, Informative

      PerlDoc.com is (was) nice but perldoc.perldrunks.org actually works!

    2. Re:CGI programs by Short+Circuit · · Score: 1

      I began learning Perl by making a city generator for D&D. That later got released. And it just went back under active development.

      Go figure.

      (If you want a more recent version, email me. The code posted is no longer suitable for submitting a patch. I'm hacking up a newer version, aiming at a decent 1.0 release soon.)

      Special thanks go to YankeeInExile.

    3. Re:CGI programs by frenetic3 · · Score: 0
      For me it was even easier. I mean, here's the only Perl script I've ever needed:

      #!/usr/bin/perl

      system "/usr/bin/python";

      ;)

      -fren
      --
      "Where are we going, and why am I in this handbasket?"
    4. Re:CGI programs by Anonymous Coward · · Score: 0

      Now, if you would attempt to learn the rules of grammar, you would be a model citizen.

  3. Link to Randal's Articles by Matt+Perry · · Score: 5, Informative

    Since there wasn't a link to Randal's collection of articles I'm providing one here. There's some excellent stuff in there.

    --
    Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
    1. Re:Link to Randal's Articles by Phillup · · Score: 1

      How is that relevant?

      --

      --Phillip

      Can you say BIRTH TAX
    2. Re:Link to Randal's Articles by wmshub · · Score: 4, Interesting

      Give it a rest. I was a coworker of Randal at the time that he committed his felonies. My opinion, which was shared by the other coworkers I spoke with ath te time, was that he was guilty of two things: lack of common sense combined with making enemies within the organization.

      As an aside, he was probably the best sysadmin I ever worked with. When you wanted something done, he got it done.

    3. Re:Link to Randal's Articles by Anonymous Coward · · Score: 0

      Just another case of being years ahead of his time. In this case, in the celebrity felon / Martha Stewart dept.

    4. Re:Link to Randal's Articles by merlyn · · Score: 4, Informative
      Thank you for that. Stupid, yes. Forgot to tell my boss everything I was working on, yes. Perhaps a bit self-serving, looking for unrequested things that'd be "good for the company" so that I'd get hired longer and more often, yes.

      But intending harm, no.

      "No harm, no foul."

    5. Re:Link to Randal's Articles by Molt · · Score: 1

      Bah, Randal's was an act of misguided intentions rather than the kind of thing you'd read about in the tabloids.

      If you're after that kind of thing you'll be glad to hear Java delivers rather nicely, with Patrick Naughton.

      --
      404 Not Found: No such file or resource as '.sig'
    6. Re:Link to Randal's Articles by Anonymous Coward · · Score: 1, Informative

      "No harm, no foul."

      I'd say three felonies and the what, $100,000+ you spent defending yourself could be considered 'foul'.

    7. Re:Link to Randal's Articles by merlyn · · Score: 2, Interesting
      I might be inclined to agree. {grin}

      I'm still suffering from that, in a sense. It did a big dent in my net assets, as well as make it harder for me to work. There are still countries that won't let me enter, although it's not a US restriction on my travel any more. There are also people that cannot (by company policy) hire a felon, so I'm ruled out there too.

      But, I've tried to make the most lemonade from the lemons I've been given.

    8. Re:Link to Randal's Articles by jcr · · Score: 1

      Another lingering effect of that fracas is that it's fairly difficult for Intel to hire clueful sysadmins these days. Every such person that I know would flip burgers before they'd take that risk.

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    9. Re:Link to Randal's Articles by smittyoneeach · · Score: 1

      No, Martha was a marketing ploy.
      Considerably more tasteful than Michael Jackass.
      Sounds as if Mr. Scwhartz committed the unforgivable sin of irritating a shark.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  4. Not an acronym! by Ohreally_factor · · Score: 1, Offtopic

    At best, it's a retro-nym.

    --
    It's not offtopic, dumbass. It's orthogonal.
    1. Re:Not an acronym! by That's+Unpossible! · · Score: 2, Informative

      It's not an acronym or a retro-nym. It's a name, Perl. It started as Gloria (after his wife) before it was released, then it was Pearl, then he released it as Perl.

      In the old days people spelled it in all caps, i.e. PERL, which was probably due to the fact that people (including Larry) like to pretend it stands for something. I am not aware of any O'Reilly books that refer to it as PERL, they all list it as Perl.

      The most common acronym attributed to it is "Practical Reporting And Extraction Language."

      (You'll note that actually spells PEARL, a hint of its early name.)

      If all is right with the world, Tom Christiansen will flame me unmercifully with everything I got wrong in the preceding story.

      JASP - Just Another Slashdot Poster

      --
      Ironically, the word ironically is often used incorrectly.
    2. Re:Not an acronym! by That's+Unpossible! · · Score: 2, Informative

      The most common acronym attributed to it is "Practical Reporting And Extraction Language."

      (You'll note that actually spells PEARL, a hint of its early name.)


      Who needs Tom C., I'll just flame myself.

      Actually it spells PRAEL. Duh, I got the wording twisted, it's obviously Practical Extraction and Reporting Language.

      Also, I am wrong about the use of PERL on O'Reilly books. I am surprised to see the PERL in a Nutshell title from O'Reilly.

      And as a twist on the theme, the pink camel book actually is called "Programming perl," with "perl" in all lowercase.

      --
      Ironically, the word ironically is often used incorrectly.
    3. Re:Not an acronym! by PepeGSay · · Score: 1

      "And" is rarely used to form the acronym. So PERL would certainly fit.

    4. Re:Not an acronym! by ajs · · Score: 1

      You are correct. It's also not dependent on who you ask. It means BOTH things, as stated by the creator of Perl, Larry Wall.

    5. Re:Not an acronym! by teknomage1 · · Score: 5, Informative
      From perlfaq

      What's the difference between "perl" and "Perl"?

      One bit.

      Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to signify the language proper and "perl" the implementation of it, i.e. the current interpreter. Hence Tom's quip that "Nothing but perl can parse Perl." You may or may not choose to follow this usage. For example, parallelism means "awk and perl" and "Python and Perl" look OK, while "awk and Perl" and "Python and perl" do not. But never write "PERL", because perl is not an acronym, apocryphal folklore and post- facto expansions notwithstanding.

      --
      Stop intellectual property from infringing on me
    6. Re:Not an acronym! by That's+Unpossible! · · Score: 1

      I understand, my point was you can see where the original "PEARL" spelling may have come from in Larry's mind. Then he changed it to Perl, some say because he saw another language named Pearl already.

      --
      Ironically, the word ironically is often used incorrectly.
    7. Re:Not an acronym! by clymere · · Score: 1
      Actually, i'm looking at my copy of "Programming Perl" right now, and its written as exactly that. Mine is the third edition however, blue, not pink.

      not that its even remotely important, but i happened to have it on the desk next to me :)

      --
      once you go slack, you never go back
    8. Re:Not an acronym! by Ohreally_factor · · Score: 1

      By "retro-nym", which I don't think is actually a word, I mean that Larry Wall (or whoever) retroactively made it into an anacronym for whatever reasons.

      Thanks for explaining the development of the name, though. It's that sort of trivia that helps make slashdot worthwhile.

      --
      It's not offtopic, dumbass. It's orthogonal.
    9. Re:Not an acronym! by Ohreally_factor · · Score: 1

      Ack!! I mean acronym. Sorry, I should probably go to sleep. But I probably won't.

      --
      It's not offtopic, dumbass. It's orthogonal.
  5. Reading Perl code? by treerex · · Score: 3, Insightful

    Because of Perl's TIMTOWTDI mantra reading other people's code can be an exercise in frustration, IMHO, because to grok what they have written you may end up delving into some of the more baroque syntax in the language. I've found that many people like writing incredibly terse code which makes its readibility incredibly difficult. While Schwartz may write comprehensible Perl, I expect that the bulk of Perl code in the wild is anything but. This is my biggest peave with the language, and how it can pride itself on this "feature" is beyond me.

    1. Re:Reading Perl code? by eln · · Score: 5, Insightful

      A good programmer will write readable code in any language he's writing in. Yes, there is a considerable faction who delight in making Perl code as obfuscated as possible, but it certainly doesn't have to be that way. C allows you to write some pretty ugly code too, but that doesn't make it a good idea to do so.

      The TIMTOWTDI ethos is ultimately what makes the language as useful as it is. The more ways there are to do things, the more things you can do with a little creativity. The Perl language is abstracted, as all higher level languages are, but it's forgiving enough to allow you to do things that may not be possible in other languages without a great deal of pain.

      The myth that all Perl code is unreadable is preposterous. I've written several very complex pieces of code in Perl that are not any more difficult to comprehend than any piece of C code designed to do the same thing, and often much less so. The phenomenon of obfuscated code is a result of poor programmers (and a pervasive subculture), not of the language.

    2. Re:Reading Perl code? by smallpaul · · Score: 3, Interesting

      A good programmer will write readable code in any language he's writing in.

      The world does not break down into three distinct camps: "Non-programmers", "Good programmers" and "bad programmers". Actually there is a spectrum and all programmers live somewhere along it. A language can encourage readability or discourage it. What does Perl do?

      The TIMTOWTDI ethos is ultimately what makes the language as useful as it is. The more ways there are to do things, the more things you can do with a little creativity.

      I'm sorry, one does not follow from the other at all. If I added a "+++" operator to C that increments by two then I now have at least three (obvious) ways to increment by two. Does that mean that I can now be more creative in C?

      The myth that all Perl code is unreadable is preposterous.

      Nobody claimed that in this thread.

      I've written several very complex pieces of code in Perl that are not any more difficult to comprehend than any piece of C code designed to do the same thing, and often much less so.

      Strange that you use C as your benchmark. How about a language designed in the last twenty years with readability as a goal? Perhaps Java, Python, Ruby, O'Caml, Haskell, etc.

    3. Re:Reading Perl code? by treerex · · Score: 3, Interesting

      I agree with everything you say, though some languages make writing read-only code easier than others. APL comes to mind immediately. I did not intend to convey the fact that Perl was unreadable. Rather I feel that Perl gives you more rope to write unreadable code than other languages, like Python.

      Of course you can write some incredibly terse code in Python too, especially with recent language additions.

      And I would not include C in a list of languages for writing readable code in.

    4. Re:Reading Perl code? by Anonymous Coward · · Score: 0

      Nobody claimed that in this thread.

      I dont believe he referred to the thread but the community in general.

      Strange that you use C as your benchmark. How about a language designed in the last twenty years with readability as a goal? Perhaps Java, Python, Ruby, O'Caml, Haskell, etc.

      I've seen some nasty Python and Java code in my time, so I don't get your point

    5. Re:Reading Perl code? by Anonymous Coward · · Score: 2, Interesting

      I completely understand your point and can even agree to a certain degree. I think what most people fail to understand about Perl's appeal is that most of the structures in Perl that drive some programmers nuts are ideas that are borrowed from natural languages and aren't found often in other programming languages.

      If you think about the idosyncracies in English (or any natural language), it's really a miracle that we can communicate with each other at all, and Perl's adoption of context and implied default variables is very similar to methods used in natural languages to make communication more succinct.

      And therein lies its appeal for some people. It's a language that you can just write, much the same way that you would write a paragraph or sentence. Most programming languages are highly structured complex sets of instructions. Perl is an actual language, and writing Perl feels more like writing English (once you become literate in the language that is).

      I think Perl appeals to hackers who like to write. I think Perl flexes some of the same mental muscles that writing and speaking flex and therefore appeals to people who tend to think in language-centric ways. It also probably explains why the primary strength of this idiosyncratic, language-like programming tool is processing text and text-like patterns. It just appeals to people who are linguistically minded and was developed with language interpretation in mind.

      That doesn't make it good or bad IMHO. It just makes it one way to approach the problem of programming. We're always talking about ways to make programming better. Using graphical tools and other advanced CASE tools to make it less like writing assembly code and more like writing a real language or doing some other non-technical task that we're already used to. Perl is an example of one way to accomplish that goal.

      It appeals to a certain mindset so it's obviously not for everyone, but that's what happens when you try new things (though I guess you could hardly call Perl new anymore). Same thing with LISP, it's a really really advanced high level language, but a large number of programmers hate it despite its power and advantages. It approaches the programming problem from a different angle and provides a unique solution that some people like and others just plain don't.

      I personally wish there were more languages like Perl and LISP to be honest. They're not always the most practical for all situations and I certainly wouldn't write every of my applications in either language, but they show us that's there more to programming than just C-like syntax and pointer arithmetic. And sometimes, really good ideas do come out of the fruit loop languages and find their way into other development tools.

    6. Re:Reading Perl code? by Umbral+Blot · · Score: 2, Interesting

      It is not that Perl is by nature less readable, however its community promotes values of terseness over readablility. For example when someone writes a quick perl script and posts it online, unless they were intending it to be used as a tutorial, far too many of the varaibles are one letter. Also Perl prgrammers tend to put more than one statment on a line by convention. While you can do this in C/C++ it is very rarely seen in the wild, unless somone is trying to be unreadable. So it's not the language, but some of its users.

    7. Re:Reading Perl code? by eln · · Score: 1

      I agree there is a problem in the community with stuff like this. Personally, I tend to ignore the community and just use the languagethe way I feel it's best used. I think things like the Perl Obfuscation Contests are good for what they do, but I think putting them up as a major argument for the use of perl is a mistake by the community.

      Perl's ability to be terse can be nice in certain situations, but it's certainly not anywhere near the top of perl's list of great strengths.

    8. Re:Reading Perl code? by swb · · Score: 1

      "Cleverness" is the highest value, and thus you have an increasing spiral of clever coders each trying to outdo the other in a language that allows for extremely flexible syntax and usage.

      The result is too often gibberish.

    9. Re:Reading Perl code? by schodackwm · · Score: 1

      Granting that TIMTOWTDI is some part of the root for unreadable code -- people, after all, do use what they know, and not always neatly -- but programmers (ok, scripters if you wish to be purist) write obfuscated code in many languages... not because of the language, but because of their weaknesses (or strengths).

      --
      [this sig has been trunca
    10. Re:Reading Perl code? by jonadab · · Score: 1

      > Also Perl prgrammers tend to put more than one statment on a line by
      > convention.

      As long as you don't overdo it *too* much, that can actually improve readability
      rather significantly, by allowing an entire function to fit on the screen at
      once that otherwise wouldn't, which makes a huge difference in how easy it is
      to read. Even in longer functions (though Perl functions longer than one
      screenful are IMO usually a symptom of bad design), fitting more context on
      the screen at once is a Good Thing(TM).

      It can, of course, be overdone.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    11. Re:Reading Perl code? by afd8856 · · Score: 1

      It takes a lot of effort to write unreadable Python code... and if you follow the rule of naming your variables good names, it becomes close to impossible not to comprehend a python program.

      --
      I'll do the stupid thing first and then you shy people follow...
    12. Re:Reading Perl code? by treerex · · Score: 1

      My issue with TIMTOWTDI and the relation to unreadable code is that it requires a greater load on the reader because they have to know (conceivably) all the ways something can be done in order to understand code from different people. TIMTOWTDI is wonderful when you are writing code for yourself, it's a PITA when you are reading someone elses code.

    13. Re:Reading Perl code? by Fahrenheit+450 · · Score: 1

      I've seen some nasty Python and Java code in my time, so I don't get your point

      I'm guessing that his point is that while you can indeed "write Fortran in any language" (and I've got a horrific chunk of OCaml code for generating random provable primes that illustrates this very well), some languages make it harder than others...

      --
      -30-
    14. Re:Reading Perl code? by m50d · · Score: 1

      Yes, but what about an intermediate programmer? I have seen perl programs that were as clear as python tutorials, but the IOCCC is a walk in the park compared to the obfustucated perl contest. And your "typical" perl script seems far less comprehensible than your typical program in any other language. Part of this is its idiomaticy - the same control flow will look more or less the same in most languages, but can be radically different in perl because of its "shortcuts". But part of it is the perl philosophy of promoting concisness, which you can't deny exists.

      --
      I am trolling
    15. Re:Reading Perl code? by rs79 · · Score: 1

      "The myth that all Perl code is unreadable is preposterous.

      Nobody claimed that in this thread.
      "

      I will. I've used C sinxe 1976 and perhaps I'm just used to it. I know three dozen computer langaugaes and prefer assembly.

      My opinion is in the gourmet world of C, Perl is nasty fast food; it may solve some short term problem but it's nasty stuff that doesn't do anybody any good long term.

      The first time I saw Java course each line made sense to me and I had a more or less instant comprehension of it. Perl just terrifies me. Each time I try to make some sense out of and modity one small part of this incomprehensible gibberish sparks fly out the back of my compter.

      --
      Need Mercedes parts ?
    16. Re:Reading Perl code? by Phillup · · Score: 2, Insightful

      A language can encourage readability or discourage it. What does Perl do?

      Perl encourages writing code.

      It leaves readability as a lesson to be learned by the programmer when he has to fix his own bugs.

      If I added a "+++" operator to C that increments by two then I now have at least three (obvious) ways to increment by two. Does that mean that I can now be more creative in C?

      That depends, if you don't know the other two "obvious" ways... but you can easily remember the "new" way... then, yes. You are now more creative. Because now you have a tool you know how to use that will let you increment by two when you need to. The other two ways weren't much use to you, because you could not remember how to use them. (I'll leave discussion as to whether you should be programming if this is the case to another thread... that isn't the point)

      I think that is the part that people don't get about Perl. It isn't necessarily about the many, many ways to do a thing. It is about doing things in ways that are easy for the programmer to understand.

      By having many ways to do a thing, chances are, one will fit your thought process better than the others... and you'll have a tool you are comfortable with. Working with tools you are comfortable with... will make you more creative. Because you will spend your energy focusing on the problem, not on how to use your tool.

      --

      --Phillip

      Can you say BIRTH TAX
    17. Re:Reading Perl code? by Camel+Pilot · · Score: 2, Interesting

      As far as readability goes I find badly written perl easier to decode than badly written C or C++. Not sure why Perl acquired the reputation of being hard to maintain. I read other peoples perl code all the time and never really had a problem. On the other hand, I have spent days on a small section of C that had includes of includes and with heavy usage of global data. Having the ability to inspect the current scoped symbol table with a print Dumper(\%main::) or Dumper(%package::) is pretty cool.

    18. Re:Reading Perl code? by jdavidb · · Score: 3, Insightful

      If you think the Perl community describes the Obfuscation contests as an argument for the use of Perl, you are confused about who the community is.

      To me, the Perl community is that group of people that does promote readable Perl. Randal Schwartz is a part of that. There is a community out there of very good programmers who love Perl, and plugging into that community has been one of the best moves of my career. The people who actually invented and maintain Perl (Larry Wall, et al) are the real community, and they are very good programmers. The fact that there are a lot of other people out there knocking off quick scripts, running obfuscated contests, and writing ignorant books without reference to the accumulated wisdom of the real Perl community is not in any way a poor reflection on the Perl community and the Perl language.

      Yes, the good programmers of the Perl community do occasionally play a round of "Perl golf" or have an obfuscation contest. But noone worth his salt has ever put those forth as if it were a positive reason to use the language.

      Good programmers who use Perl use Perl because it is possible to write very good, high quality, modular, readable code in Perl. The people who actually create Perl exemplify and encourage this.

    19. Re:Reading Perl code? by ajs · · Score: 2, Interesting

      "Of course you can write some incredibly terse code in Python too, especially with recent language additions."

      Yep. EVERY language can be bent to horrid non-readability.

      If you want a language that enforces readability, I would suggest using Perl 6 (the first MAJOR step in the actual implementation of which was just made with the creation of a Haskell-hosted compiler called pugs) and writing a module which enforces your idea of readability. Perl 6 will be the first language to give you enough control that you can write this kind of requirement in the language itself. Common LISP comes in a close second, so use that in the mean-time if you want such levels of dictatorial control. Of course, you could write a module that allowed the rest of your program to be written in CL in P6 quite easily ;-)

      PS: y=x+++1 Guess what language that is. Answer: C, C++, Python and Java. Perl too if you just add $ before y and x. Programming languages are ugly.

    20. Re:Reading Perl code? by John+Bokma · · Score: 1

      Same holds for any language I have seen. Beginners often make a huge mess which is unreadable for more advanced programmers. I have seen unreadable C, C++, Perl, PHP to name a few. Perl is often unreadable for the same reason as PHP: people just download garbage programs, tweak it, and publish it. GIGO.

    21. Re:Reading Perl code? by rs79 · · Score: 2, Insightful
      Warning: I'm grouchy. A CPU fan failed and let the smoke out of a new chip. I also discovered by accident Windows has a (320x240) television mode; it took me hours to unfuck somebody's PC.

      "And I would not include C in a list of languages for writing readable code in."

      I can understand how you can feel that way after looking at some of the C code that's out there. But you have to go out of your way to obfuscate C. There's a reason there's no obfuscated Perl contest: "everybody's a winner!".

      It's possible to write readable code in C. Not many people do it, I'll agree but this does not mean it cannot be done and you learn for your own beenfit, in time, to write very clear, lots of whitespace, one idea per line code. DMR's "one true brace style" is as much to blame for the obfuscation and unreadability IMO, as anything, and while he and I disagree on this, our understanding we've agreed to is as long as you can read and write both, that's ok. Keep in mind his justification is based on physical limitations of 24 line 80 column crts.
      if (thing == that){
      pritnf ("This sucks, Dennis.");
      }
      or
      if (thing == that)
      {
      printf ("My kids can understand this.");
      }
      C is a simple langauge with not that many operators, but it requires discilpine to write code you can go back to in 6 months or a year and still tell at a glance what it's doing.

      I also do not buy the "perl has more features" argument. If you need to do something often enough you write yourself a set of routines and use them as a black box library. My "web" one is 10 yrs old. Prior to that I carried around the same one for decades and with slight modes it worked from (real) Unix to CP/M to MS-DOS. Things got a bit fuzzy around the edges with Amiga and Windows GUI code, but they did not last long in my world. My one Windows gig was my last, it was too revoting to take seriously; I'm not into masochism.

      I would encourage aybody whose written a quick Perl hack to write it again in C as much for the learning experince as for the benefit of crusty farts like me who are sick of 7 levels of dependancies. Grabbing "the needed library" seems to be a recursive loop without end and I've given up many times trying to run some perl thing and found in most cases it's easier just to write it in C, which, once you're used to it you can do very very quickly. I will grant that it take a fair amount of time to overcome the learning curve but IMO it's absolutely worth it.

      To address the original point I have no problem with APL, Forth or Poscript. While they take a day to get used to, they're simple, fun and elegant. Parl just makes me hurt all over.

      At the risk of being permanently banned fom slashhdot forever I believe 1) Linux is more popular than BSD not because it's better in any sense, but because it's easier to install, and 2) Perl, similarly so, provides an instant gratification at a penalty of readability and to some extent, performance. I prefer "short term pain for long term gain" and shortcuts are just that. My grandmother said it best: "quality is the only economy".

      --
      Need Mercedes parts ?
    22. Re:Reading Perl code? by eln · · Score: 1

      I admit I haven't been part of the Perl community for many years, although I've continued to actively use the language. So where does one go to tap into the "good" part of the community these days? Any pointers you have would be appreciated.

    23. Re:Reading Perl code? by rgmoore · · Score: 1

      There is a corresponding readability advantage to TIMTOWTDI, though. Frequently a second way of doing things is included specifically because it makes some particular problem easier. A function that lets you do in one like what otherwise would have taken ten does require you to learn a new function, but it also saves you from writing (and future coders from reading) nine lines of code every time you use it. That may hinder readability for the novice, but it enhances it for the expert. YMMV.

      --

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

    24. Re:Reading Perl code? by Eravnrekaree · · Score: 1

      Being a heavy perl programmer and someone who has used perl extensively for a long time, I disagree completely that Perl code is more difficult to read than other languages on average, or that Perl encourages people to write bad code. I have found that writing good, easy to read code is as natural as any other language. If people are going to write bad code, I believe they will write bad code in any language they use. Perl's TIMTOWTDI is actually a key feature in keeping Perl readable and avoiding ugly hacks since the programmer is able to choose the feature that most clearly and best expresses what they are trying to do rather than try to devise ugly hacks to try to circumvent ridiculous limitations of a language. Of all of the languages for which I have read code, this includes Java, and Python, Perl code for me is the clearest and the most easily understood on average, because it does not place a lot of limitations on what can be done and make certian things far more difficult than they need to be through such limitations, and gives you the choice and freedom of many ways to do something.

      Furthermore, I believe Perl should remain Perl and give programmers complete freedom to do what they need to do and allow them many ways to do it. If you want a language that places restrictions on you and decides what features and things you should be allowed to use, where the language designers impose their opinions and tastes on you through placing arbitrary restrictions on how the language can be used, please feel free to use the language of your choice that does that. There are plenty of them out there.

    25. Re:Reading Perl code? by pileated · · Score: 2, Interesting

      Yes I think that's right. Perl gives you far more rope to write unreadable code with. And for some reason people delight in doing so. I really do think that it's part of the Perl culture.

      I'm sure I'm not alone in having spent a lot of time thinking about this over the years. I've recently had to both rewrite someone else's Perl code and write some new stuff of my own. What I noticed immediately is how easy it is to write something complicated in Perl and how easy it is to write code that is so terse that no one else will be able to understand it without considerable work. Worse I really think that the dominant Perl culture, as much as there is one, disdains comments and clear code in favor of terse and clever code. And Perl surely lets you do that.

      I should add that Perl is my primary language. But I also do a fair amount of Java coding and it sheds some interesting light on Perl. Yes it is incredibly verbose. But it also is much better about forcing you do consider error conditions. Perl by contrast allows you to THINK that you have a working program without informing you of the possible error conditions that exist. Yes I know about -w and use strict and they help. But not everyone uses them. As I said it's still my main language. But there sure are times when I liked to send it to Java school for a little discipline.

      On related matters I'd really recommend "Effective Perl Programming" by Joseph N. Hall, with Randall.

    26. Re:Reading Perl code? by jdavidb · · Score: 4, Informative
      • use Perl; is a good place, but very informal and tends to get sidetracked into politics :)
      • Your local Perl mongers group may be a great place
      • YAPC (Yet Another Perl Conference) and the Perl conference (now part of the Open Source conference) usually have many good presentations by the truly great Perl programmers
      • I have the impression that Perlmonks is pretty good, though I don't tend to use it much
      • Finally, the Perl5 Porters mailing list is the real original heart of the Perl community, though I think nowadays many of those guys have moved onto Perl6 work

      A list of names is also useful: material by Damian Conway, Larry Wall, Randal Schwartz, Mark Jason Dominus, Simon Cozens (Perl involvement now minimal due to career change), and persons associated with them is going to be top notch. Plug their names into Google and see what they have to say. Catch a presentation or read a book by one of them if you can. Meanwhile, there is truly a lot of junk out there. There's an article out there somewhere about "how to tell a good Perl book from a bad Perl book," which I thought was by Mark Jason Dominus, but I can't seem to find it at the moment.

      Finally, 90% of the useful modules you'll see recommended for use from CPAN are written by the intelligent lights in the Perl community. The time-tested modules that are now standard solutions are those that were written with high quality by good programmers.

    27. Re:Reading Perl code? by jdavidb · · Score: 1

      I think you've conflated the Perl community with some other group of people. The real Perl community values program clarity, modular and readable code, and high software quality. Yes, there are some games to make the tersest programs possible, but the guys out there like Larry Wall who actually write Perl do not feel that way.

      Please see also this post.

    28. Re:Reading Perl code? by Anonymous Coward · · Score: 4, Insightful

      By having many ways to do a thing, chances are, one will fit your thought process better than the others... and you'll have a tool you are comfortable with.

      This speaks to the developer's experience, not the code maintainer's. The code maintainer is stuck maintaining code idioms not of his choosing: and the more idioms there are, the more idioms the maintainer needs to understand to maintain them all.

      Working with tools you are comfortable with... will make you more creative. Because you will spend your energy focusing on the problem, not on how to use your tool.

      Again, this balances developer comfort ("I get to choose the best fit of ten expressions! Woot! I'm so comfortable!") against maintainer comfort ( "I have to know ten different ways to maintain ten different developers code. Why can't they all just pick one! *grumble*").

      Maintaining someone else's code is usualy harder than writing your own, for the comfort factor you cited. A development culture that accepts esoteric ways to write code can be a nightmare, because the coder's defense is always There's More Than One Way To Do It.

      If there's One Way To Do It, and that's what the coder did, then I know exactly what it does. If there's One Way To Do It, and the coder didn't quite do that, then I've found a bug, or the coder wrote something subtle, and didn't comment it clearly. In either case, the fact that the code needs fixing stands out clearly.

      If There's More Than One Way To Do It, and what the coder did isn't clear, then I have to think hard to decipher what's going on, and whether it is what it appears to be, or whether it's some subtle little Perl trick.

      In short, TMTOWTDI helps developers, but at the expense of maintainers, and QA staff charged with proving code correctness.
      --
      AC

    29. Re:Reading Perl code? by niittyniemi · · Score: 2, Informative

      > I agree there is a problem in the community with stuff like this.
      > Personally, I tend to ignore the community and just use the language the way I feel it's best used.

      I started getting into Perl about 5 yrs ago and subscribed to comp.lang.perl.misc

      I have never come across a newsgroup inhabited by so many arseholes.

      The flaming of newbies was encouraged and posting obfuscated code par for the course. There was an overwhelming sense of how many Perl programmers thought themselves a cut above everybody else; full of people who would handily put obfuscated Perl in their sigs so that you could straightaway identify them as:

      (a) A language snob.
      (b) A fucktard.

      I unsubscribed from the group but persisted with Perl. For me, Perl fills the gap between shell scripts and pukka standalone apps (it's even pretty easy to GUIfy a script with Tk).

      I found the best resources to be the Camel book and Cookbook from O'Reilly.

      I bet a lot of people got put off Perl by that group at that time - God curse their black souls! It was a shame because there were some good contributions on the group from people like Randal.

      --
      The Machine stops.
    30. Re:Reading Perl code? by mplex · · Score: 1


      That's just because you are a C programmer and C syntax ie Java and the like look familiar too you. If you used Perl since '76 (I know that's impossible) you would have similiar problems with C/++/Java. I have learned and use both languages and with experience comes readability.

    31. Re:Reading Perl code? by Anonymous Coward · · Score: 0

      > Also Perl prgrammers tend to put more than one statment on a line by convention.

      Show me one module in CPAN coded like this.

      And frankly if you think perl is unreadable, you havent worked with C++ templates that much. This is a language that requires just to start making sense of its compiler errors.

    32. Re:Reading Perl code? by snorklewacker · · Score: 1

      Why don't you go take a look at Template-Toolkit from CPAN and tell me how unreadable it is. If you can't tell me what it's doing from reading the code, you're probably not competent in any programming language.

      --
      I am no longer wasting my time with slashdot
    33. Re:Reading Perl code? by treerex · · Score: 1

      "Yep. EVERY language can be bent to horrid non-readability."

      It is hard to write unreadable Python. It is not hard to write Python that is so "high-level" that you have to spend a lot of time figuring out what it is actually doing. A complex list comprehension can lead to some powerful code that does an amazing amount of stuff in a neat little package. To me this is different than the arbitrary line-noise you get with Perl.

      So Perl 6 lets you define your own syntax so that someone reading your code neads to figure out what your ideas of the Right Language is? Wonderful. That will make things better for everyone.

      Common LISP and Scheme's macro facilities can be used to define your own language constructs: see Paul Graham's On LISP for details on this. Or you can use the full power of SGML to redefine the characters in your "language". Or hell, TeX lets you redefine the world if you are so twisted, though to me TeX is more unreadable than Perl.

    34. Re:Reading Perl code? by snorklewacker · · Score: 1
      I say this as someone who likes perl and even defends its readability, but sometimes ... Let me rummage for about 10 seconds through some typical perl code I work with.
      push @{$category->{$label}}, $p->{id};
      I may understand perfectly what this does, but I just can't stand how damn noisy it all is

      --
      I am no longer wasting my time with slashdot
    35. Re:Reading Perl code? by treerex · · Score: 1

      Well, this is really a benefit of code reading in general: learning other ways of doing something. The problem (as I see it) with TIMTOWTDI is that there are too many ways of doing some things, and these compound one another. Sure, if you read enough Perl you'll learn every possible of way of doing something in the language, but at what cost?

    36. Re:Reading Perl code? by SilicaiMan · · Score: 3, Interesting
      If I added a "+++" operator to C that increments by two then I now have at least three (obvious) ways to increment by two. Does that mean that I can now be more creative in C?

      You give an extremely naive example. Even Perl doesn't allow you to do that ;-)

      But, consider this. Perl allows you to postfix your if() statements, like so:

      wave() if $person_seen eq 'Paul';
      This is much more naturally readable than:
      if ($person_seen eq 'Paul') { wave() }
      Similarly, you can use unless to make code easier to read:
      buy_food() unless you_forgot_your_wallet();
      This allows you to emphasize that buying food is the norm, and you would normally do it unless you forgot your wallet. The equivalent negative-if form does the exact same thing, but does not allow you to express your intent as well as this does.

      This is the essence of TMTOWTDI. You don't HAVE to use alternate ways to do things if you don't want to. But it does help most of the time in conveying your intent when you wrote the code, which make it more maintainable.

      Once I read someone comparing Perl to the human brain. The brain is a double-edged sword: it can compose the most pleasing melodies and most beautiful literature, but at the same time it can hatch evil plots of large-scale genocide and mass murder. Creativity has a dark side to it. Attempting to suppress that side will severly hinder the creative process. Same thing goes with Perl.

      I think Larry got it right.

    37. Re:Reading Perl code? by rs79 · · Score: 1

      That's probably true to some extent but it does not explain why I took to, say, Forth and Postscript easily.

      Even good Perl looks to me like somebody rolled their head on the kayboard.

      --
      Need Mercedes parts ?
    38. Re:Reading Perl code? by Chrax · · Score: 1

      In my experience, it requires a bit of knowledge of the subtleties of perl to write anything that could not easily be unraveled with proper spacing. And if you use good variable names, instead of the perl trademark single character variable names, it's not at all difficult to visually parse it.

      Actually when I was first learning perl, once I got over the idea of scalars, I could read through the program I was looking at with no trouble.

    39. Re:Reading Perl code? by Anonymous Coward · · Score: 1
      And how is this
      category->get_label().push( p->get_id() );
      any more readable?
    40. Re:Reading Perl code? by Chrax · · Score: 2, Insightful

      I more or less learned perl and C cotemporaneously, so I see where you're coming from. But really, once you get over the idea of no real data types, and learn a couple of the tricks perl does in order to drop extra variables, it's not a big deal, and I think it's time well spent learning.

      And while yes, Java is easy to understand, it's just another step in the C line that, in the end, doesn't allow for the flexibility of perl, or rather can't be both as flexible and compact as perl.

    41. Re:Reading Perl code? by rgmoore · · Score: 1
      The problem (as I see it) with TIMTOWTDI is that there are too many ways of doing some things, and these compound one another.

      But that's really a separate issue. TIMTOWTDI isn't about the fact that there are lots of possible ways of coding a solution to a particular problem- that's true of any language. TIMTOWTDI is about Perl being non-orthogonal, i.e. built-in functions have overlapping capabilities.

      To use an analogy, Perl has a larger vocabulary than other languages. Where a deliberately orthogonal language might have just one word meaning "of above average size" (big), Perl has several (big, huge, enormous, gigantic). That's annoying for people who are learning the language because they keep having to look words up in the dictionary, but it's great for accomplished speakers because they can say precisely in one word something that would require a whole phrase in another language.

      At the same time, I wonder how true it is that Perl really has a huge vocabulary compared to other languages. Part of it is that Perl has builtin functions that are part of libraries in other languages. Is C really that much simpler than Perl if you include its standard libraries for things that are already built in to Perl, like IO, string manipulation, type manipulation, memory management, etc.?

      --

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

    42. Re:Reading Perl code? by Chrax · · Score: 1

      I don't know if there are any official obfuscated perl contests, but it's a common enough game we play. Usually it's in the form of golf, because reducing to the fewest elements is an excellent test of skill and knowledge of the langauge's nuances.

      Also, I agree with rewriting things in C (unless of course they involve text parsing, at which point perl is the tool of choice). Perl scripts are handy to get things done fast, but for some reason I feel that projects are more *done* in C. Maybe it's the speed boost.

    43. Re:Reading Perl code? by Chrax · · Score: 1

      I feel just the opposite. I've played with Java a bit (even took a class). The whole time, I kept thinking "Java would do a lot better to be perl."

    44. Re:Reading Perl code? by Chrax · · Score: 1

      I found comp.lang.perl.misc to be helpful as far as it went. Of course you can't waltz in and ask a stupid question, just like you can't in comp.lang.c.

      However, I quickly realized that the only answers you get are going to be using someone's idiom of choice, and rarely do they come with adequate explanation.

      As far as putting obfuscated perl in their sig, that seems to be a rather common attribute of perl users. They're just for fun, I have encountered very few actual language snobs.

    45. Re:Reading Perl code? by Anonymous Coward · · Score: 0

      Hey, at least C is better than C++.
      Whats up with that?

    46. Re:Reading Perl code? by pileated · · Score: 1

      Well I have to admit that when I took my first Java course I kept mentioning to class that I thought Perl was better in many ways.......

      But now a few years later, and now that I'm doing and rewriting more production Perl code, I see how fragile it can be. And wish it forced a little more discipline on itself.

      That said I think for those who use it you can't help but love it for what it does. I don't have much sympathy with those who take easy but ignorant pot shots at Perl. But on the other hand I think it could do much, and its users could do much, to help make it more robust and give it the respect it deserves.

      It's just seems too hard to make robust Perl code and that really bothers me.

    47. Re:Reading Perl code? by ajs · · Score: 4, Informative

      "A complex list comprehension can lead to some powerful code that does an amazing amount of stuff in a neat little package. To me this is different than the arbitrary line-noise you get with Perl."

      There you just lost me. The term "line noise" implies a low signal-to-noise ratio, when in fact Perl presents exactly the opposite. The SIGNAL is in fact, so high that many programmers find it difficult to cope with. That's fine, but let's not confuse that with actuall NOISE.

      "So Perl 6 lets you define your own syntax so that someone reading your code neads to figure out what your ideas of the Right Language is?"

      No. You wholy misunderstood the concept.

      In Perl 6, you will have full access to the grammar, so you could enforce your local stylistic conventions. You would obviously not want to make INCOMPATIBLE changes so that your code is still valid Perl, but you could write your own "strict".

      Think of it this way. Imagine a C++ header that caused all uses of operator overloading outside of a limited few "neccessary" to be illegal, or that issued a compiler warning on every use of an iterator initialization outside of a for loop. These are just simple (and not very useful) examples, but they serve to illustrate the point: you can instrument the compiler just as fully as you can instrument your code. Don't like the type checking in Perl 6? Make it stricter.

      I'm sure that there will be someone who will publish the "python-like bondage" module 15 minutes after Perl 6 is released. If you're into that sort of thing, then your company can take full advantage of it, while still getting all the value of Perl 6 like LISP-style currying and macros, Ruby-style mixins, cross-langauge bindings through Parrot, boxed and unboxed type constraints on standard Perl scalars, full multi-method dispatch, etc., etc.

      "Common LISP and Scheme's macro facilities can be used to define your own language constructs"

      Yes, but we're not talking about defining language constructs. We're talking about changing the behavior of the compiler in structured, standardized ways that aren't just implementation hacks. Don't get me wrong. Common LISP is on my list of cool languages to learn more about right below Python and Ruby. I'm just saying that these particular Perl 6 features bear a bit more looking at.

      "Or hell, TeX lets you redefine the world if you are so twisted, though to me TeX is more unreadable than Perl."

      TeX is actually a good example of what I'm talking about. TeX is very readable for a full typesetting system, but most of us could not care less about typesetting. When you need to do specific tasks that INVOLVE typesetting, but you don't really need all of that power and flexibility, you step up a layer of abstraction and turn TeX into LaTeX. LaTeX is valid TeX, so it's not quite the same, but the idea of limiting a powerful system in order to step back a level of abstraction holds.

      Perl 6 will provide all of the power that you need from a modern high-level programming langauge, but let you manage that complexity. You might decide, for example, to restrict Perl 6 in your programs to just the facilities that make sense for scientific calculation. You might even introduce a special syntax/grammar for putting differential equations directly into your program without having to quote around them and hand them off to a seperate processing tool (object, module, what-have-you).

      None of this is useful for your average 1000-line CGI program, but for the company that produces tens to millions of lines of structured libraries upon which new software is built and re-factored over time, this will all be a godsend.

      Much of what Perl 6 brings to the table, Common LISP has done for years, but some of it is either gathered from other, more recent langauges (e.g. Python, Ruby, Scheme, Java, etc.) or is, as far as I can tell, unique. I hope you give it a try and throw away your naive ideas of "line noise" in favor of considering the value to your productivity and the maintainability of your code base.

    48. Re:Reading Perl code? by Chrax · · Score: 1

      "It's just seems too hard to make robust Perl code and that really bothers me."

      Yeah, whenever I write a non-CGI script, I feel like it's a rushed job because it's very difficult to take care of unexpected input as gracefully as you can in other languages. Thus, unless it involves parsing, I typically redo my scripts in C sooner or later.

      Incidentally, I have the same problem (or at least feeling of the problem) with Java, and it doesn't do handily that which I require of it, which is why I can hardly stand to use it.

    49. Re:Reading Perl code? by rs79 · · Score: 1

      "I more or less learned perl and C cotemporaneously, so I see where you're coming from. But really, once you get over the idea of no real data types, and learn a couple of the tricks perl does in order to drop extra variables, it's not a big deal, and I think it's time well spent learning."

      Back in the bad old days when dinosaurs roamed the streets and computers had switches and pretty blinky blinky lights all was FORTRAN and/or Assembler or diety-forbid RPG, COBOL or DIBOL. I used Assembly almsot exclusively (the alternative was clearly, suicide or plumbing) and C, when and where I could, that is to say "not much". This was the mid to late 1970s. Over the years the ratio of C to Assembly inverted and I haven't written an Assembler instruction in over a decade. But, as anybody who writes in Assembler knows there are no data types, just arbitrary bytes and word in memory. So that's no great hurdle to get over.

      Perhaps I'm drain bamaged, or maybe I have a mental block, I don't know. It's not like I haven't tried to figure Perl out but I'm incapable of even getting to first base, while I feel any idiot can add a print statement ("printf ("got here.");") to a C program.

      I wouldn't say C encourages readability, bit it doesn't make it impossible, unlike, IMO, Perl.

      --
      Need Mercedes parts ?
    50. Re:Reading Perl code? by rs79 · · Score: 1

      " whenever I write a non-CGI script, I feel like it's a rushed job because it's very difficult to take care of unexpected input as gracefully as you can in other languages. Thus, unless it involves parsing, I typically redo my scripts in C sooner or later."

      You might end up as I have with a set of precanned library routines you've written that take care of any input that's thrown at you. If you get a new input format, you modify an existing library routine or just write a new one.

      If I have an input field that's a dollat amount and may or may not have a dollar sign and can't have any non-numeric except possibly a decimal point which may be omitted and I need the result as either an integer in number of cents or a sting, with two decimal places and nodollar sign, well, I have a routine that does that (now). I don't even think twice about sich things any more. Granted it's a bitch starting from scratch.

      C doen't even have any I/O in the language, unlike say, PL/I It all takes place in the libraries. So you end up writing your own to supplant, not replace stdlib.

      The error checking is everything. I have nothing but disdain for programmers that leave one out. Everytime I use a piece of software, whether it's industrial grade unix code or some windows hack and I get an "undocumented program execution" (bug) I curse the prick that didn't check for this. I know it's painful and I can't count the number of nights I've been sitting here ar 4 am still handling error conditions for some feature I tried to implement at 11 pm... but you have to, no two ways about it.

      I think I write ok C code, but IMO if you want to look at how C code should be written look at Dan Bernstin's stuff (cr.yp.to). It's so beautiful it makes me cry. And noboy has get found a bug he offers a decently sized cash reward for finding.

      --
      Need Mercedes parts ?
    51. Re:Reading Perl code? by rs79 · · Score: 1

      "Perl's ability to be terse can be nice in certain situations,"

      Like what? Your floppy disk is almost full?

      --
      Need Mercedes parts ?
    52. Re:Reading Perl code? by rs79 · · Score: 2, Interesting

      "...Mark Jason Dominus..."

      Oh shit now I know I'm old. I see that name and "Perl" dosn't even come to mine. talk.bizarre does.

      --
      Need Mercedes parts ?
    53. Re:Reading Perl code? by rs79 · · Score: 1

      "I started getting into Perl about 5 yrs ago and subscribed to comp.lang.perl.misc

      I have never come across a newsgroup inhabited by so many arseholes.
      "

      Try getting more than two newsgroups then. or you must be getting an NNTP feed from an interdimensional gateway. Here on earth most of them are filled with beings only slightly more advanced than plasmodium.

      --
      Need Mercedes parts ?
    54. Re:Reading Perl code? by SimHacker · · Score: 1

      Oh. My. God. This guy is such a great example of why Perl programmers just don't get how horrible the language they're evangelizing is. Dude: it's ok to use it privately, just don't try to convince other people to make the same mistake.

      --
      Take a look and feel free: http://www.PieMenu.com
    55. Re:Reading Perl code? by SimHacker · · Score: 2, Insightful
      "Don't get me wrong. Common LISP is on my list of cool languages to learn more about right below Python and Ruby."

      Please, work your way a little bit further down that "list of cool languages to learn more about", before telling people they should use Perl.

      --
      Take a look and feel free: http://www.PieMenu.com
    56. Re:Reading Perl code? by evrybodygonsurfin · · Score: 1
      There's an article out there somewhere about "how to tell a good Perl book from a bad Perl book," which I thought was by Mark Jason Dominus, but I can't seem to find it at the moment.

      You're maybe talking about Michael Schwern's Perl book litmus test.

    57. Re:Reading Perl code? by rjshields · · Score: 1
      But, consider this. Perl allows you to postfix your if() statements, like so: wave() if $person_seen eq 'Paul'; This is much more naturally readable than: if ($person_seen eq 'Paul') { wave() }
      I think that's subjective. It doesn't strike me as being intuitive if you've never used it before.
      --
      In this world nothing is certain but death, taxes and flawed car analogies.
    58. Re:Reading Perl code? by hachete · · Score: 1

      Having more than one way to do things is neat until you start maintenance. Just that more futz to learn. Makes it an *expensive* language to maintain - expense in terms of skills to learn and time.

      I agree that having multiple ways to do things may make it more comfortable for the programmer - but it's at the expense of easier maintenance.

      Readability shouldn't be a lesson learned by a programmer. We all - even the stars amongst us - have to maintain other people's code. We should be kind to ourselves more often.

      Then again, I'd say never write a perl program more 100 lines. If you've got a battery of tests, then maybe 500 lines. Anything else is foolhardy - I know. I'm paid to maintain 8000 lines of the stuff and it gives me nightmares.

      h

      --
      Patriotism is a virtue of the vicious
    59. Re:Reading Perl code? by mwlewis · · Score: 1

      It's intuitive in the sense that it's following natural language conventions. We often speak this way. People who code perl often code this way.

      --
      JOIN US FOR PONG!
    60. Re:Reading Perl code? by treerex · · Score: 1

      "But that's really a separate issue. TIMTOWTDI isn't about the fact that there are lots of possible ways of coding a solution to a particular problem- that's true of any language. TIMTOWTDI is about Perl being non-orthogonal, i.e. built-in functions have overlapping capabilities."

      It isn't about the vocabulary (well, not much: have four words for the same concept is just stupid in a programming language, IMHO). It's about syntax: consider the four or five different ways of writing references! Syntactic sugar on top of syntactic sugar. It's rediculous.

    61. Re:Reading Perl code? by chthon · · Score: 1

      Although I already program for five years in Perl, I also really can't stand the noise, especially on datastructures.

      However, Perl is not the only language with this deficiency.

      Since most languages like Perl, Python and Ruby use hashes as substitutes for records, I also find something like

      var = record['fieldname']['field2']

      too noisy.

      Granted, you can declare a class and add members which are accessible using the '.' notation, but I find it cumbersome.

      I work much with large datastructures, and I like it much better the way they are handled in COBOL, ie. predeclare them to have one single point of truth, and all members on all levels accessible by just concatenating them with dots.

    62. Re:Reading Perl code? by SilicaiMan · · Score: 1
      (Score:1, Troll)

      Hmmm .. may I know why my post was modded as Troll? I didn't criticize any other languages, nor did I instigate a language war or flame anyone. As a long time Perl coder, I was just giving my opinions.

    63. Re:Reading Perl code? by SilicaiMan · · Score: 1
      I think that's subjective. It doesn't strike me as being intuitive if you've never used it before.

      That's correct, but then everything is subjective. Python's strict use of white space is subjective; C's use of pointers is subjective; etc.

      Different people have different experiences and expectations, so not all languages will appeal to everyone.

    64. Re:Reading Perl code? by Fahrenheit+450 · · Score: 1

      But, as anybody who writes in Assembler knows there are no data types, just arbitrary bytes and word in memory.

      Pssst... assembly languages have got types now...

      Pass it on.

      --
      -30-
    65. Re:Reading Perl code? by jdavidb · · Score: 1

      No, that wasn't it, although that is certainly similar. The essay I remember had more tests, longer comments about them, and few if any actual books mentioned.

    66. Re:Reading Perl code? by snorklewacker · · Score: 1

      > Granted, you can declare a class and add members which are accessible using the '.' notation, but I find it cumbersome.

      I always liked the way Javascript did it, making the dot mere syntactic sugar. Certainly the dot notation is much nicer than perl5's awful arrow notation, something it borrowed from C++, which itself borrowed from C. The ironic thing about that is that C never even needed that arrow notation, because the usage is never ambiguous (and it is in C++ only in the most extreme corner cases). It only existed because the implementation was hamstrung by exceedingly dumb compilers that weren't aware enough of the types. -> is C's extraneous "sigil", much like perl's $%@.

      It looks like perl6 is getting rid of the arrows (yay) and different sigils for the most part (looking somewhat tclish if i dare say so) ... it'd sure be nice to have a working perl6 though (yes I know about pug, but it's hardly ready for for anything but experimenting with the idea of perl6 itself, not even toy programs)

      BTW, I'd like to thank you for offering one of the few reasonable mature replies I've gotten on perl threads so far. I suppose I really should stop talking about it, since it seems to be just flamebait like python's indentation or lisp's parenthesis.

      --
      I am no longer wasting my time with slashdot
    67. Re:Reading Perl code? by schodackwm · · Score: 1

      True... but it's a PITA to try to write or read something in a language with strictly constrained alternatives -- if you don't know all the constraints.
      Guess what I'm suggesting is that it's a "skill level" issue. Show hello.c to many third-graders and they'll have a hard time reading that.

      --
      [this sig has been trunca
    68. Re:Reading Perl code? by ahdeoz · · Score: 1

      But it takes very little effort to cut and paste unexecutable Python code.

    69. Re:Reading Perl code? by slycer · · Score: 1

      and um.. "printf ("got here.");" to a perl program produces the exact same results :)

    70. Re:Reading Perl code? by afd8856 · · Score: 1

      I presume you refer to web pages. I've never found this to be a problem. Usually the python editors replace the tabs with spaces (4 of them) and when you use this with a pre tag or whitespace preserving css, you'll have no problem.

      I think python far surpases its whitespace problem through ease of use, clarity of language and cool software available.

      --
      I'll do the stupid thing first and then you shy people follow...
  6. Hooray! by Kimos · · Score: 2, Funny

    Another punny title!!

  7. $subject by Anonymous Coward · · Score: 3, Funny

    I really $feeling $author. His contributions to $language were $adverb $adjective. I really hope he $does_doesnt[int rand(1)] write more books. The are $adverb2 $adjective2.

    1. Re:$subject by Anonymous Coward · · Score: 0

      You $verb it.

    2. Re:$subject by Anonymous Coward · · Score: 0

      $does_doesnt[int rand(1)]

      $does_doesnt[rand 2]

  8. Next title in this series by Anonymous Coward · · Score: 1, Funny

    If one can write a book about good Perl style,
    I expect to see next:

    "Portrait Painting With Dog Vomit"

    1. Re:Next title in this series by rs79 · · Score: 1

      "If one can write a book about good Perl style,
      I expect to see next:

      "Portrait Painting With Dog Vomit"


      I guess one mans flamebait is anothers +5 insightful...

      --
      Need Mercedes parts ?
  9. Explanation? by eskwayrd · · Score: 1

    Each column has been reproduced as it was written in the original magazine, with "Randal's Note" prepended. Therein lies this book's best feature and greatest flaw. Allow me to explain.

    Perhaps I missed it. But where is the explanation of 'best feature' and 'greatest flaw'?

    --
    eskwayrd = m^2c^4
    1. Re:Explanation? by schodackwm · · Score: 1
      Columns are as published; not re-written -- RTA thru.

      or is understanding why that is both a "feature" and a "flaw" hard? If so, consider the span of years... and changes in perl and its modules, over those years

      --
      [this sig has been trunca
    2. Re:Explanation? by eskwayrd · · Score: 1

      Columns are as published; not re-written -- RTA thru.

      I did RTA. What makes you think I did not?

      or is understanding why that is both a "feature" and a "flaw" hard?

      <shrug> Perhaps it's just semantics. Had the reviewer not said 'Allow me to explain', I wouldn't be looking for an explanation.

      Also, the reviewer used the term 'Therein', which means 'That is where the problem lies,' not 'That _is_ the problem.'

      The explanation may be just as you suggest. If not, it was not included in the review.

      --
      eskwayrd = m^2c^4
    3. Re:Explanation? by exley · · Score: 1

      The submitter of this review was just practicing obfuscated reviewing techniques.

  10. Tip #1... by MoeDrippins · · Score: 5, Funny
    --
    Before you design for reuse, make sure to design it for use.
    1. Re:Tip #1... by Macrobat · · Score: 1
      One thing to remember is that Randal did that in order to alert Intel to the insecurity in their passwords. If I remember the story right, he went to his bosses at the time and said "I think there might be some insecure passwords on our network."

      "Don't worry about it," was the alleged gist of the response, but Randal insisted. When they said that there was no problem, that's when he ran Crack and presented them with the list of passwords, to prove that they were insecure. That's when they slapped the criminal charges on him.

      My take on it has always been, I'd have fired him (because when your boss tells you specifically not to do something, it becomes his problem not yours, and disobeying a direct order is a firing offense); I wouldn't have pressed charges, though.

      Actually, I would have listened to him in the first place, but, for better or for worse, his orders were to steer clear of the password file.

      --
      "Hardly used" will not fetch you a better price for your brain.
    2. Re:Tip #1... by Anonymous Coward · · Score: 0

      "Don't worry about it," was the alleged gist of the response, but Randal insisted. When they said that there was no problem, that's when he ran Crack and presented them with the list of passwords, to prove that they were insecure. That's when they slapped the criminal charges on him.

      Well, he ran crack on one machine, then USED at least one cracked account to get on another machine to do the same thing. Very very egregiously bad and wrong. Still, I think pressing charges was going too far.

    3. Re:Tip #1... by rs79 · · Score: 1

      "Well, he ran crack on one machine, then USED at least one cracked account to get on another machine to do the same thing. Very very egregiously bad and wrong. Still, I think pressing charges was going too far."

      Maybe, maybe not. There's two sides to every story and I don't know both sides to this one.

      If he was there to fix the accounting system I'd have had him killed, not sued.

      Id he was there to beef up security then they fired the wrong person - maybe. Senior management seldom takes kindsly to the idea some programmer just founf a way to read their email.

      There are two ways he could have handled this better 1) get some really nasty dirt on all the senior management from their emial, ala Simon BOFH, or 2) (and this assumes security is in scope of his gig) tell the CEO (Mr. "My door is always open here at Intel) what the problem is and what you'd like to do. If he says it's ok and you got it in writing, not email then go ahead and so it.

      You can't help somebody that doesn't want yor help.

      --
      Need Mercedes parts ?
  11. learning languages by bungley · · Score: 3, Insightful
    In my opinion, the best way to learn any language well is to see how others have used it to solve problems.
    Strange, everyone else I've spoken to EVER has said the best way to learn a language is through practice. Then again, I suck at programming.
    1. Re:learning languages by Anonymous Coward · · Score: 0

      He said learn a language well, not learn a language. There's a difference. To learn a language takes practice practice and more practice. To advance to the next level requires studying the code and examples of those better than you.

    2. Re:learning languages by foobsr · · Score: 1

      the best way to learn a language is through practice

      I wonder if there is anything that this does not generalize to.

      Perhaps committing suicide succesfully.

      CC.

      --
      TaijiQuan (Huang, 5 loosenings)
  12. Perl doesn't kill readability... by jqh1 · · Score: 5, Insightful

    People kill readability (with Perl).

    Seriously, choose the right tool for the job. When we've got a sys-admin level scripting task, and someone can go in and knock it out in a half hour (or less) with a few lines of Perl, who can say that's bad? I'm currently wading through a bunch of heavily patternized java that pulls checkin logs from a scm system and updates an issue tracking system as part of the build process. It's taken me *days* to begin to "grok" what's going on in the many associated xml config files and bizarre string handling approaches that were used in this undocumented hack. I'll replace it with probably less than 150 lines of Perl, and someone else will happily (and much more easily) maintain it. So there!

    At the same time, we've got > 25 developers distributed around the world working on a big commodities trading app -- java works pretty well for that.

    --
    who's moderating the meta-moderators?
    1. Re:Perl doesn't kill readability... by bani · · Score: 1

      i've been gradually moving towards python and php for scripting. both are far more readable than perl, and just as powerful. yes really, php makes a nice scripting language -- there's far more to it than just spitting out html from apache.

    2. Re:Perl doesn't kill readability... by m50d · · Score: 3, Insightful

      Yes, but perl is a hair-trigger for you. Obfustucating C or Java takes a bit of effort. Obfustucating Python is pretty hard, your best bet is to lambda over everything and hope the reader isn't a primarily lisp programmer. Obfustucating perl can be done without thinking. Seriously, perl is a tool for quick scripts that will be rewritten rather than edited. It's designed for things which take up less than one page of code to write. It's fast to write short programs, but you should think again before writing a big one in perl, maybe try and chain some small ones together instead.

      --
      I am trolling
    3. Re:Perl doesn't kill readability... by elmegil · · Score: 1
      both are far more readable than perl

      Horse Hockey. The only "unreadable" languages are the ones designed to be so. Perl is not. I can write just as much line noise crap in PHP as anyone ever did in Perl, especially given that they have perl regular expressions built in...

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    4. Re:Perl doesn't kill readability... by Anonymous Coward · · Score: 0

      HAHAHAHAHA. PHP is some "wannabe" language that is trying to desperately hard to be perl. It started off as perl and they should have just left it as perl. Now after 5 versions they're just barely approaching perl4. Who knows when they'll get to the level perl5 is already at? If you're going to use a perl like language, don't cripple your self with a crappy derivative like php, use the original.

    5. Re:Perl doesn't kill readability... by ajs · · Score: 5, Interesting
      "People kill readability (with Perl)."

      As they do with C, C++, Java, Snobol, Forth, APL, C#, etc, etc.

      Half of the people programming are below-average programmers. Bad programmers can make life HELL in C, and by the same token good programmers can make life quite easy in Perl.

      That said, Perl gets a bad rep, not because good code is hard to read, but because a) bad code is more common in any language which is easy to learn and b) Perl has several features which people mistake for non-readability (that is, non- or inexperienced Perl programmers assume that code is hard to read because they don't know Perl and see these things which scare them):

      • Regular expressions - This is a common feature in almost all languages these days, but the ease with which they are integrated into Perl syntax makes them more common in Perl programs. Of course, you have to be careful about the amount to which you let such constructs take over your code, but Perl was the one to introduce whitespace formatting and comments into regular expressions for just this reason.
      • Typing glyphs - Many programmers from the C/Pascal/Fortran - derived world take exception to the prefix-characters in Perl. Some Perl programmers find it hard to read C code that uses subroutines, complex data structures and simple types without any indication of what's being accesed or how. It's a matter of time and exposure on BOTH sides, and being a programmer in both worlds, I can tell you that both are equally readable with sufficient exposure.
      • Context sensitivity - Perl's context sensitivity spans every level from the way the tokenizer works all the way up to the handling of large-scale data structures. This is the nature of a language designed by a linguist. It "reads well", but only when you start trying to read it like a spoken language, and not a mathematical code. Software source code has always been somewhere in the middle-ground between those two extremes, and it's jarring at first that Perl moved the line so much, but give it a while and you find that it's much easier to think and communicate complex ideas (by complex, I mean cognitive complexity, not code complexity) in Perl than in any other programming language.
      • Weak typing - This is a matter of religion, but I'll make a footnote of it anyway: Perl is weakly typed, and that frustrates many who are used to strong typing. Neither is better or worse, though the fact that Perl 6 will (as Common LISP has done for quite some time) give you both is a boon, I think.

    6. Re:Perl doesn't kill readability... by moof1138 · · Score: 3, Insightful

      I have had to deal with a lot of Perl, Java, and PHP. The nastiest ugliest code I ever inherited was PHP. I agree that Python tends to be more readable since it has a more limited... expressiveness... than Perl, but PHP with it's endless heap of little functions that do nearly the same thing and its oddly inconsistent namespace can mutate as readily as Perl, especially when wielded by an inexperienced programmer.

      --

      Hyperbole is the worst thing ever.
    7. Re:Perl doesn't kill readability... by Fahrenheit+450 · · Score: 2, Insightful

      Regular expressions - This is a common feature in almost all languages these days, but the ease with which they are integrated into Perl syntax makes them more common in Perl programs.

      And this is exacerbated when people pull out all sorts of jiu-jitsu to apply regexes to problems that are better and more cleanly handled with a general purpose lexer. But I can see where pulling out a lex-alike doesn't work too well when you're dashing off a script.

      Perl is weakly typed, and that frustrates many who are used to strong typing.

      Actually this isn't quite right. [confession_mode=on]A couple of weeks back I ranted a bit about this and the whole "a number is a string is a boolean..." nature of Perl and how this implied weak typing. Well after thinking about it for a while, I realized that Perl is actually strongly typed with respect to its (fairly unconventional) type system. The fact that the type system is so unusual is what troubles most people (myself included).[confession_mode=off]

      --
      -30-
    8. Re:Perl doesn't kill readability... by bani · · Score: 1

      but PHP with it's endless heap of little functions that do nearly the same thing

      you mean perl isn't littered with the same problem? hah. one of the touted features of perl is that there's always a zillion ways to do the same thing.

      the thing i hate the most about perl is the often implicit behavior of perl. explicit programming is almost always clearer. perl freaks would claim this just demonstrates the power of perl, but it sure doesn't lend to its readibility.

      the retarded perl syntax for defining functions doesnt help readability either.

      and can someone explain how perl stuff like

      $|=1;

      is in any way clear and intuitive?

    9. Re:Perl doesn't kill readability... by chromatic · · Score: 1

      I disclaim the question. What part of natural language (especially English) is "intuitive"?

      Still, see perldoc perlvar. Every special variable has a mnemonic and an optional extended name, if you use the English module. For $|, it's "when you want your pipes to be piping hot".

    10. Re:Perl doesn't kill readability... by streepje · · Score: 1

      Half of the people programming are below-average programmers.

      And how many slashdot posters are below average statisticians?

      After all, more that 99% of all people have more than the average number of legs.

    11. Re:Perl doesn't kill readability... by PylonHead · · Score: 1

      This is exactly right.

      I don't use perl for anything that will take more than 1/2 hour, or require more than a page of code.

      Except that these short programs slowly start to expand into massive behemoths as I constantly add one more feature. Soon it's unmanageable.

      So I've been trying to code my scripts in OCaml to begin with. I've been playing around with "CASH" a bit. Not sure I'm in love with it, but I no longer fear the code getting out from under me.

      --
      # (/.);;
      - : float -> float -> float =
    12. Re:Perl doesn't kill readability... by snorklewacker · · Score: 1

      you mean perl isn't littered with the same problem? hah. one of the touted features of perl is that there's always a zillion ways to do the same thing.

      Yes, but they're not a zillion functions with inconsistent conventions all littering the global namespace all doing the same thing.

      I don't expect you to recognize all the tricks in perldoc perlbot, but if you can't understand the pre and post forms of if and the precedence of and and or vs && and || (after a little practice for that one), then you are merely incompetent. Stay well away from heavily templated C++ code, and under no circumstances allow yourself to get near functional languages, or you will collapse in sheer incomprehension. There's More Than Perl's Number Of Ways To Do It in those languages.

      --
      I am no longer wasting my time with slashdot
    13. Re:Perl doesn't kill readability... by Anonymous Coward · · Score: 0

      Ooh aren't you clever. Except we can and typically do define the scale of ranking so average==median, at least for an ideal scale. I bet you have the median number of legs.

    14. Re:Perl doesn't kill readability... by Fahrenheit+450 · · Score: 1

      under no circumstances allow yourself to get near functional languages, or you will collapse in sheer incomprehension. There's More Than Perl's Number Of Ways To Do It in those languages.

      Huh?

      I find functional languages to be much cleaner and more consistently coded in than Perl[1]. Could you provide a couple of examples of this syntax smorgasbord you're talking about?

      [1] Of course, there are always examples of arcane and overly complicated ways of doing things, such as this example. But I'm speaking in generalities here...

      --
      -30-
    15. Re:Perl doesn't kill readability... by Anonymous Coward · · Score: 0

      but PHP with it's endless heap of little functions that do nearly the same thing

      one of the touted features of perl is that there's always a zillion ways to do the same thing

      There is a subtle difference: PHP functions do nearly the same thing, while Perl has many ways to do exactly the same thing.

    16. Re:Perl doesn't kill readability... by friedo · · Score: 1
      And this is exacerbated when people pull out all sorts of jiu-jitsu to apply regexes to problems that are better and more cleanly handled with a general purpose lexer.

      That's what Parse::RecDescent is for.

    17. Re:Perl doesn't kill readability... by nihilogos · · Score: 1

      $|=1 is shorthand for $OUTPUT_AUTOFLUSH = 1, which is about as clear and intuitive you can get when specifying that the output buffer should be flushed after every print or write. If you want to be clear and intuitive, then you shouldn't be using shorthand.

      And, on a personal note, PHP has got to be one of the most boring languages ever invented.

      --
      :wq
    18. Re:Perl doesn't kill readability... by donio · · Score: 1

      Common Lisp is always strongly typed. Perhaps you mean that it's dynamically typed and that type declarations are optional.

    19. Re:Perl doesn't kill readability... by Anonymous Coward · · Score: 0

      hah. you can't even write basic html, and he's supposed to take your word for it about code readability? lol.

    20. Re:Perl doesn't kill readability... by SimHacker · · Score: 1
      "Perl has several features which people mistake for non-readability"

      If people "mistake" the Perl features for non-readability, then aren't the features actually causing people to make mistakes? Are you saying that people are just mistaken that they're confused by Perl, and actually they understand it perfectly, but they just don't realize it?

      How can you write this stuff without realizing what it really means? Are you just a Python programmer making fun of Perl programmers by pretending to evangleize Perl?

      -Don

      --
      Take a look and feel free: http://www.PieMenu.com
    21. Re:Perl doesn't kill readability... by m50d · · Score: 1

      Do try Python. It's not for everybody, but you'll be a better programmer for having tried. And I love it.

      --
      I am trolling
    22. Re:Perl doesn't kill readability... by merlyn · · Score: 2, Insightful
      There are messy desk people, and clean desk people. If you force someone who normally works with a messy desk to have a clean desk, their productivity goes down. Likewise in reverse.

      Similarly, there are Perl people, and there are Python people. One is not better than the other. It just matters on a manner of fitting.

      Please stop with the "one is better than the other" stuff. Better for you perhaps.

    23. Re:Perl doesn't kill readability... by smittyoneeach · · Score: 1
      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    24. Re:Perl doesn't kill readability... by m50d · · Score: 1

      It doesn't work like that for programming languages. Force someone to program in a different language and you will make them a better programmer, no matter what their opinion of it is. Learning perl made me a better python programmer, and learning python will make perl programmers better perl programmers. And if you haven't tried python, you don't know if you'll like it. I generally dislike functional languages, but I'm now learning Haskell and enjoying it, so it's worth trying even a language of a type you normally don't like.

      --
      I am trolling
    25. Re:Perl doesn't kill readability... by Fahrenheit+450 · · Score: 1

      Erm... what the hell does that have to do with "functional languages"?

      I know that template meta-programming and Boost allow you to do functional programming in C++. However, it's a layer of ugliness (Template MP) on top of a layer of ugliness (C++), on top of a layer of ugliness (C) and hardly the same thing as actually using a functional language like OCaml, Haskell, or Scheme.

      Would you like to try again?

      --
      -30-
  13. Re:It's always amused me... by Tackhead · · Score: 1
    > It's always amused me...
    > that such a f'ugly language should be named with an homonym of such a beautiful thing as a pearl.

    Huh? I just finished converting my codebase from Brainfuck to Perl, because I found Perl to be a little bit more readable.

    And that guy muttering to himself in the corner isn't crazy. He's just our Ook porting lead.

  14. TIMTOWTDI acronym expanded by PornMaster · · Score: 3, Informative

    For those trying to follow along but not able to immediately expand the acronym, TIMTOWTDI is There Is More Than One Way To Do It.

    1. Re:TIMTOWTDI acronym expanded by Anonymous Coward · · Score: 0

      whore

  15. Perl and work by synx · · Score: 1, Interesting

    I used to do small scripts in perl and I originated a fairly complex system in Perl which was written as if it was C++ (no direct access of object values, only methods, etc).

    However having said that, I also later inherited a system written in Perl. Thousands of lines, lots of complex data structures. This experience permanently soured me on Perl. While it is possible to write good code in Perl, this doesn't always happen. Especially with the sense that perl is a scripting language that you use to develop hacks or short scripts. The temptation to do a shortcut is too great.

    This leads me to another annoyance: Magic. Perl is too magical. To be truly effective in Perl you must know most or all of the magic. If you are unfamiliar with an idiom you have to resort to the manual/books. This means there is not a simple guiding principle (ie: abstraction) you can take and apply to problem solve any situation. The movement to exceptional magical cases is backwards thinking.

    None of this matters if you're sitting at home writing one-off cgi-scripts (which is how perl became most famous), but once you move into the area of "professional" development, or at least large scale coordination, you quickly see the value in simple readable code.

    In the end, most people who get paid to write code are rewriting and enhancing existing code. If it takes a week to understand a 500 line perl script, the code has probably delivered negative value to your team and company!

    1. Re:Perl and work by sisukapalli1 · · Score: 1

      While it is possible to write good code in Perl, this doesn't always happen. Especially with the sense that perl is a scripting language that you use to develop hacks or short scripts. The temptation to do a shortcut is too great.

      Problems with readablility of Perl code is a sort of a chicken and egg situation. People develop "prototypes" in Perl, and there is almost an expectation of "throw away code". To contrast this with Java, there are people that write a class with a main method with everything in there. In good institutions, there are mechanisms to ensure that the Perl code is maintainable. In many places, the general practice is that "if it compiles and runs, it is great!" Java enforces some structure (but many people still manage to ruin it in Java anyway -- not properly passing exceptions, or always simply puking out stacktraces).

      The problem is that the PHBs view Perl as a simple scripting language, and the developers are tempted to meet that standard. However, if the boss says, "Well, we'll have a review of the code," the developers may be tempted to write more maintainable code.

      If one follows some simple guidelines regarding coding, one's code will go a long way and stay easily understandable. The best reference people should be guided to the CGI.pm module (see the source, the usability, etc.)

      S

    2. Re:Perl and work by gurps_npc · · Score: 5, Insightful
      You made an error that I think a lot of people make.

      It is not how long it takes you to understand a perl script of X length that is relevant.

      What SHOULD be the important data is: Whether it would take you MORE time to understand a C or Java program that does the same thing.

      I have seen cases where people complain that it takes them a week to understand a Perl Script of 500 lines. So they write a new program in C, that does the same thing in 5,000 lines. Which then takes me 8 days to understand.

      One of Perl's image problems is that because it does so much with so little, people underestimate what the tiny program does and therefore get frustrated when it takes them more time to understand than a C program of the same size, even though the C program does 1/10 what the Perl one does.

      --
      excitingthingstodo.blogspot.com
    3. Re:Perl and work by bani · · Score: 3, Insightful

      that's part of the problem with perl -- the code is often incredibly terse and dense.

      you can do incredibly complex things in a few characters in perl, which can be far more difficult to grok than the same thing described in 20 lines of C code.

      it's both a blessing and a curse. a blessing because you can beat out very complex things quickly, and a curse because it is a major pita to maintain.

      perl also stubbornly avoids some useful language constructs in the name of "language purity". eg case statements. yes i know about Case.pm, but its not stock perl. and yes i know perl6 will have it. only took them ~20 years to get there :-P

    4. Re:Perl and work by rogerallen · · Score: 1

      Why would you compare to C or Java instead of Python or Ruby?

      I've heard many people suggest that usually the same script in Python is much more understandable.

    5. Re:Perl and work by Qzukk · · Score: 1
      a Perl Script of 500 lines. So they write a new program in C, that does the same thing in 5,000

      What does the following Perl command do, how does it do it, and how many lines of C would it take you to produce the same output (not necessarially the same way!)
      perl -le '(1x$_)!~/^(11+)\1+$/ && print for (2..100)'
      --
      If I have been able to see further than others, it is because I bought a pair of binoculars.
    6. Re:Perl and work by m50d · · Score: 2, Insightful

      It still takes more effort for me compared to python. Not compared to C, but C takes lots of instructions to do simple things - use only when necessary. And I think the problem is that the syntax is so different. You throw a c/java/python/etc. program at a programmer from another language and they'll get the basic idea. They'll be able to see where the functions are, how the control flow goes, with a little bit of effort what the variables are. You throw a perl script at someone who hasn't seen perl, and a few are alright, but most look like so much line noise. You have to relearn a lot of your programming knowledge, and if perl isn't your only language then you have to switch modes when you see it. If I could program with it all the time, it would be good, but the fact is I have to use C and Java a lot of the time, so I need a language which isn't too different from them.

      --
      I am trolling
    7. Re:Perl and work by gurps_npc · · Score: 1
      I am not saying that Perl can not be intentionally written poorly. Anyone can do that with any language.

      For example I could say "My name is Andrew."

      OR I could say: My name is an anagram of "Wander" with the last two letters swithed and then take the first letter and move it to the back.

      Or I could say: The first letter of my name has the same first letter as the fruit traditionally used to represent the fruit of Knowledge in the bible. The second letter....

      --
      excitingthingstodo.blogspot.com
    8. Re:Perl and work by ajs · · Score: 1

      LISP has always had the same exact problem. In fact, the creator of Perl, Larry Wall, once said that LISP had all of the visual appeal of oatmeal with fingernail clippings mixed in (an obvious jab at the use of parens which is no more valid that the jabs against Perl for the use of $). And now, Perl 6 is borrowing HEAPING amounts of old wisdom from Common LISP in order to improve the power and flexibility of the langauge (from the way it does macros to currying to the way blocks are built as functional units instead of as C-style lexical scopes).

      I'm not putting Larry down, here, just pointing out that languages which make it easy to do a large job in fairly little real eastate are often beset with this kind of short-sighted thinking from even otherwise level-headed folk. It's a good thing that we grow up and get past it.

    9. Re:Perl and work by Kismet · · Score: 2, Interesting

      While I think yours is a fair assessment, there is one other aspect that needs to be emphasized:

      Perl syntax is very flexible. You can write Perl that looks something like C, or Perl that looks something like Basic, or Perl that looks something like Java, etc.

      You might get two Perl programmers who both write small, efficient programs to do the same thing using similar architectural and design approaches. Both programs could look radically different, depending on the author's slant on Perl.

      That is what makes reading Perl difficult.

    10. Re:Perl and work by John+Bokma · · Score: 2, Insightful
      Well written, and agreed. instead of: s/foo/bar/i; people somehow prefer:
      private RegExpThingy re = new RegExpThingy;
      try {
      re.compileASearchAndReplaceCaseInsensitiveThingy( "foo", "bar" );
      re.doDaSmartThingyOnAStringy( sumvar);

      } catch RegExpCompilingFUBARException {
      /* ignore it */
      }
      I wonder why... the days one got 0.10 USD a line are over, or not?
    11. Re:Perl and work by kneeless · · Score: 2, Insightful
      perl also stubbornly avoids some useful language constructs in the name of "language purity". eg case statements. yes i know about Case.pm, but its not stock perl. and yes i know perl6 will have it. only took them ~20 years to get there :-P
      From the Camel:

      Unlike some other programming languages, Perl has no offical switch or case statement. That's because Perl doesn't need one, having many ways to the same thing. A bare block is particularly convenient for doing case structures. Here's one
      SWITCH: {
      (!$whatever) && do { &go("yes"); last SWITCH; }
      ($something) && do { &go("no"); last SWITCH; }
      ($nothing) && do { &go("???"); last SWITCH; }
      $somethingelse = 1;
      }
      After this, there are four other examples showing this in more ways. Go get the Camel, it's invaluable.
    12. Re:Perl and work by Camel+Pilot · · Score: 1

      Good point!

      Recently I went the other way with rewritting a C windows program in perl. A section of the code was parsing a string sent from an rfid reader with temperature measurement. The prior author spent 2 pages of code tokenizing and using a if/elseif/else and cases structures which I replaced with a single well written regexp. The regexp is compaction of meaning and is much easier to understand.

      Secondly the prior application used a "ping" to test if the interface was up. Again the original C programmer spent over 100 lines of code dropping down to do socket connections using select etc. I used Net::Ping and two lines and was done. Could the guy have used a C ping library? Maybe i don't know, but I spent no more than 10 minutes researching, installing and implementing the Net::Ping code with no prior experience or knowledge of the module.

    13. Re:Perl and work by bani · · Score: 1

      sorry, but that does not lend itself to readable code. if anything your example proves how badly perl suffers from not having a true switch syntax.

      also, perl6 will have official switch statements, so apparently they decided that this "doesn't need one" claim was false. only it took them 20 years to come to that conclusion.

    14. Re:Perl and work by Anonymous Coward · · Score: 0

      You forgot to catch SmartThingyException and StringyTokenReaderConverterStreamParserAdaptorHand lerException, so it won't compile..

    15. Re:Perl and work by asuffield · · Score: 1
      You throw a c/java/python/etc. program at a programmer from another language and they'll get the basic idea.

      Oh really?

      Care to explain this? I spent an hour or two deciphering it last week:
      while ((low ^ (low+range)) < TOP || range < BOT &&
      ((range= -low & (BOT-1)),1)) {
      code=(code << 8) | getc();
      range <<= 8; low <<= 8;
      }
      There's above five thousand more lines of similar code in that one.

      I've seen similar crap in java and python as well, and at least as often as I've seen it in perl. Bad programming is language-agnostic.

      You throw a perl script written by somebody who is not crap at programming at somebody and they'll be able to see how it works. You give them anything written by a chucklehead like the one who wrote the above, and they're screwed regardless of language.
    16. Re:Perl and work by Anonymous Coward · · Score: 0

      Case statements are for morons. Why add syntactic sugar that makes it easier for you do write your program the wrong way? If you had a clue, you'd be using a dispatch table. That's a hash with subroutines, in case you don't know.

      Bad way:

      if ('first option' eq $choice) { # do this
      } elsif (...) { # do that ...
      } else { # do default
      }

      Better way:

      sub first_option () { # do this }
      sub second_option () { # do that }
      sub default_option () { # do default }

      my %dispatch = (
      first_option => \&first_option,
      second_option => \&second_option, ...
      default_option => \&default_option );

      # use dispatch table
      if (exists($dispatch{$choice})) {
      &$dispatch{$choice}();
      } else {
      &$dispatch{'default_option'}();
      }

      Best way involves using objects.

    17. Re:Perl and work by Anonymous Coward · · Score: 0

      Perl can be as terse as you need or as enterprise as you want. When I write a one-off, I tend to make use of the -lane options. These can get ugly.

      For production code, I got the other way. I'm heavily into inline documentation and testing with POD and Test::Inline. And of course the almost mandatory Log::Log4perl goes into just about everything I build. Developers and maintainers don't have a hard time reading and understanding my code, they don't have a hard time extending it either. QA guys love it because it comes with built in tests to prove correctness of functions. Ops guys love it because on those rare occasions when it breaks, it's easy to diagnose the problem and fix it.

      Perl is ultimately just a very flexible tool. How well you use it is up to you.

    18. Re:Perl and work by rs79 · · Score: 2, Funny

      "Care to explain this?"

      Easily. A young white male who had taken too much caffeine smoked a joint at 4 am to calm down at on a project that was way overdue and underfunded had to add several things to his code to make it work by trying them at random; eventually it worked but he can't explain why.

      How'd you get access to the MX missile codebase just out of curiosity?

      --
      Need Mercedes parts ?
    19. Re:Perl and work by rs79 · · Score: 1

      "Secondly the prior application used a "ping" to test if the interface was up. Again the original C programmer spent over 100 lines of code dropping down to do socket connections using select etc. I used Net::Ping and two lines and was done. Could the guy have used a C ping library? Maybe i don't know, but I spent no more than 10 minutes researching, installing and implementing the Net::Ping code with no prior experience or knowledge of the module."

      An easy way to do that in C is to shell out to ping and check the return value. That 3 lines of code shouldn't even take 10 minutes and you aren't relying on some unknown code you grabbed from someplace that may or may not have, um, undesirable side effects or create dependancy problems when it or Perl changes.

      --
      Need Mercedes parts ?
    20. Re:Perl and work by SimHacker · · Score: 1
      The thought of Perl avoiding useful language constructs in the name of "language purity" is like fighting for peace, fucking for virginity, or Anne Nicole Smith going on a low-carb diet so she can shovel handfuls of Crisco into her mouth.

      -Don

      --
      Take a look and feel free: http://www.PieMenu.com
    21. Re:Perl and work by Camel+Pilot · · Score: 1

      One word "portability"

    22. Re:Perl and work by m50d · · Score: 1

      It's clearly a while loop, and which bit is the loop body and which is the conditional is also clear. The body is bitshifting "code" to the left and then doing something involving getting a character; a bit of thought and you can probably see it's appending characters onto the end of "code". Then it's multiplying range and low by 256. Looking at the conditional it's pretty clear something OR something else AND something more. That first something would be confusing if you didn't know that ^ is XOR in c, yes, but that's a minor thing. The last bit is someone doing assignment in a conditional, trying to be leet, and so it's hard to understand, yes. But the basic structure at least is clear. Bad people can write bad code in any language, yes, but good people seem to be able to write bad perl easily. I've seen examples in perl books that would be incomprehensible without knowing perl, just something like while(){chomp;print} which is good perl (assuming I've remembered the syntax for print right) makes no sense unless you know how perl works. It's a while loop, yes, but wtf is it whiling? And what are those words in the body doing? Print is obviously printing, but printing what?

      --
      I am trolling
  16. Effective perl coding by Repton · · Score: 0, Troll
    # perl -e 'system("apt-get install python")'
    --
    Repton.
    They say that only an experienced wizard can do the tengu shuffle.
  17. To be frank, any help is better than most books by WillAffleckUW · · Score: 1

    While I tend to prefer the camel series, it's not unusual to crack open a perl book and try to find a chapter that actually tells you how to do something - and then find that it's nigh unreadable.

    So, given that it's based on fairly readable columns, this would still be a useful book.

    Now if I can just figure out why the warnings spit out when I refer to a hash table result as the input to a hash table, saying it's an uninitialized value when, in fact, that value has been initialized, then I might be able to run things thru Perl with the -w flag more often.

    --
    -- Tigger warning: This post may contain tiggers! --
    1. Re:To be frank, any help is better than most books by John+Bokma · · Score: 1
      "Now if I can just figure out why the warnings spit out when I refer to a hash table result as the input to a hash table, saying it's an uninitialized value when, in fact, that value has been initialized, then I might be able to run things thru Perl with the -w flag more often."

      replace -w with the use strict; use warnings; combo (or add even use diagnostics;)

      If you disagree with the Perl warnings: print to see what happens, or better: use Data::Dumper; and do a print Dumper $var;

    2. Re:To be frank, any help is better than most books by Anonymous Coward · · Score: 0

      Like this?

      use strict;
      use warnings;

      my $bill;
      my $bob;

      $bob->{'eatme'} = 10;
      $bill->{$bob->{'eatme'}} =100;

      So whats the problem? No warnings here.. Maybe you were trying my $bill->{$bob->{'eatme'}} =100; in one shot?

    3. Re:To be frank, any help is better than most books by Anonymous Coward · · Score: 0

      When you think that the value has been initialized and Perl says that it has not, Perl is usually right. Don't sweep that under the carpet, find your typo and fix it.

      As another poster pointed out, using strict can help you do that.

    4. Re:To be frank, any help is better than most books by WillAffleckUW · · Score: 1

      replace -w with the use strict; use warnings; combo (or add even use diagnostics;)

      If you disagree with the Perl warnings: print to see what happens, or better: use Data::Dumper; and do a print Dumper $var;


      I know why it gives that warning, but it's just annoying. My point is that, by definition, it isn't undefined, it's just a poor warning.

      --
      -- Tigger warning: This post may contain tiggers! --
    5. Re:To be frank, any help is better than most books by John+Bokma · · Score: 1
      "I know why it gives that warning, but it's just annoying."

      Ok, I misread, I read can't in the below:

      "Now if I can just figure out why the warnings spit out when I refer to a hash table result as the input to a hash table, saying it's an uninitialized value when, in fact, that value has been initialized,"

      If you mean that:

      $h2{ $h1{foo} } = 'bar';

      gives you a waring, of course. If you really want this:

      use strict;
      use warnings;

      my %h1;
      my %h2;

      {
      no warnings;
      $h2{ $h1{foo} } = 'bar';
      }

      print $h2{ '' };

      What happens (guess): the value is stringified (to '') and hence the complaint that the hash slot of h1 is not initialized (which is not, it doesn't exist). It's the same warning as you get with:

      my $a;
      print "$a";

      $a has not been initialized (by you), but internally it has undef as a value.

      Note that the magic in Perl is limited, often for good reasons.

      Now you can see why use warnings; is better compared to -w, since then you are aware of no warnings :-)

    6. Re:To be frank, any help is better than most books by WillAffleckUW · · Score: 1
      Fairly close, except that in my example $h1{foo} has already been initialized in a prior statement as:
      %h1=();
      %h2=();
      $foo = 0;
      $h1{$foo} = "baaramewe";
      $h2{ $h1{$foo} } = "bar";
      minus a heck of a lot of lines, naturally.

      As I said, just because I know why a warning is kicked out doesn't mean it's not incredibly annoying.
      --
      -- Tigger warning: This post may contain tiggers! --
    7. Re:To be frank, any help is better than most books by John+Bokma · · Score: 1
      Then you clearly made an error, since the above code shouldn't and doesn't give a warning. I changed it to:
      use strict;
      use warnings;

      my %h1=();
      my %h2=();
      my $foo = 0;

      $h1{$foo} = "baaramewe";
      $h2{ $h1{$foo} } = "bar";
      And works perfectly, as it should.
  18. Buy this Book by KingOfTheNerds · · Score: 1

    Being a big fan of Randal Schwartz's Perl column, I bought this book when it first came out. I find his writing clear and concise, and easy to understand even for beginners. The best part of this particular book is chapter 3 which I used to learn how Perl was used on the web, and it helped me to create many of the scripts that I use for my own website.

    --
    Want to learn about anything sexual? Check out the sex wiki:
  19. Re:First Use Python Post by WillAffleckUW · · Score: 1

    If you have to read 6 books and 200 columns to learn a language, then the language is a fucking mess, and should be abandoned to the scrapheap of history.

    Took me a lot more than that to learn English as a small child (Go Dogs Go!) or French, German, and Latin later on.

    Are you saying we should be speaking grunts and clicks instead? Or should we just use binary and nod our heads and shake them?

    It's a poor programmer who blames his lack of skill with using tools on the tools themselves.

    --
    -- Tigger warning: This post may contain tiggers! --
  20. Re:Quote by redtux1 · · Score: 1, Offtopic

    not everyone - never seen the attraction of php

  21. perlmonks by Porag_Spliffing · · Score: 4, Informative

    For anyone getting into perl I can not recomend The Perl Monks Monastery enough. Lurk for a while, use super search to find the answers to almost any perl question you may have and if all else fails post to Seakers Of Perl Wisdom and enlightenment shall surely follow.

    Randal is a regular contributor there and many of the other leading lights of perl pop up frequently.

    Regards,
    A monk.

    --
    Maybe you live in interesting times
  22. IMPOSTER!!! by MisterLawyer · · Score: 2, Informative

    Randal Schwartz's Perls of Wisdom will never take the place in my heart that is forever occupied by Steve Litt's PERLS of Wisdom!

    1. Re:IMPOSTER!!! by Anonymous Coward · · Score: 0

      I prefer their elegant line of perl necklaces!

  23. Re:Uhhh.... by Anonymous Coward · · Score: 1, Funny

    When I was a tad, we didn't have all these fancy newfangled languages. We were so poor, we were glad to have two bits to rub together. We had to make everything from bits. Why, I remember one time, I wanted a dog, so I made one from bits. He was a little buggy, but he was the best damn dog a boy from the bit-mill ever had. I wore my fingers to bloody nubs flicking toggle switches on that front panel. But I learned the value of hard work and perseverence. Not like you youngsters these days with your nancy keeyboards and you poofter mice.

  24. Dear Mr review writer... by rjshields · · Score: 4, Informative
    my ($f) = 'fortune';
    Should use back ticks instead of single quotes like so:
    my ($f) = `fortune`;
    Otherwise you assign the string "fortune" rather than the output of the fortune program ;)
    --
    In this world nothing is certain but death, taxes and flawed car analogies.
    1. Re:Dear Mr review writer... by r3lody · · Score: 1

      The original review had the backticks. For some reason, during the translation to HTML, they got converted to simple single quotes. My bad. I should have read the HTML more carefully.

  25. Domo Arigato, Raymond Lodato by Anonymous Coward · · Score: 0

    Sorry...

  26. The example in the article is wrong... by Anonymous Coward · · Score: 1, Informative

    For example, the first column reproduced in the book (It's All About Context) explains why, when someone used my ($f) = 'fortune'; instead of my $f = 'fortune'; he got in trouble with the law (see the book to understand the legal issue)

    In the example above, the single quotes should be backquotes instead.

    my $f = 'fortune'; will just assign the string "fortune" to $f. This is what the article has, and it's wrong.

    my $f=`fortune`; will run a program called "fortune", and assign it's output to $f.

    my ($f)=`fortune`; will assign the first line of the output of the fortune program to $f.

  27. Schwartzian Transforms and raised hackles... by Fahrenheit+450 · · Score: 3, Informative

    Randal also discusses formatting and the nifty "Schwartzian Transform" (Perl's map-sort-map idiom for sorting on almost anything) which was named for him, but not by him.

    This is one of the things that's always annoyed me about Perl and its practitioners (well, most programmers, really)...

    Given the long history of functional programming (hell, Lisp is closing in on 50 years old), this map/sort/map idiom had to be second nature to any Lisp/Scheme/Haskell/ML/etc. programmer at the time Schwartz wrote about it back in 1996[1]. And the fact that this was such a revelation to the people who read his column that they named the idiom after him just exposes the lack of a diverse programming background for most people. I'm guessing that 50% of the coders out there wouldn't know a map or a fold if it bit them on the ass, and even more wouldn't have a clue as to how to solve something so basic as the missionaries and cannibals problem in a declarative/logical manner (without the help of Dr. Google that is).

    Meh... Bitter rant over, I guess...

    [1] I could be wrong, I didn't really do much coding before 1995-ish.

    --
    -30-
    1. Re:Schwartzian Transforms and raised hackles... by merlyn · · Score: 4, Informative
      I've actually said your exact point a number of times. In fact, I didn't "invent" anything. I was solving someone's problem, who had posed the problem in the Perl newsgroup, using the knowledge I had at hand. As I'm also a LISP hacker (see my "pretty printer" in the GNU Emacs distribution), I simply relied on my knowledge of simple list manipulation techniques to transform the problem into something workable.

      I had no idea it would take on a life of its own as a standard idiom. And it was not originally "for a column". It was a usenet posting and wasn't presented as anything remarkable.

      Just trying to set the record straight.

    2. Re:Schwartzian Transforms and raised hackles... by Fahrenheit+450 · · Score: 2, Interesting

      Just trying to set the record straight.

      Oh, don't worry, I'm not blaming you or calling you out or anything like that. Hell that column at the least opened a few eyes, and that's a good thing. It's just that the ST term is one of the triggers that set off some variant of a bitter "programmers need to learn more paradigms/languages" rant in me...

      And the voices in my head won't go away until I vent it somehow...

      --
      -30-
    3. Re:Schwartzian Transforms and raised hackles... by rblackwe · · Score: 1


      Check out http://pugscode.org/

      What is Pugs?

      Pugs is an implementation of Perl 6, written in Haskell. It aims to implement the full Perl6 specification, as detailed in the Synopses. For more information, please see the overview.

    4. Re:Schwartzian Transforms and raised hackles... by teknomage1 · · Score: 1

      I love it when I see celebrities on slashdot! And witha 4 digit ID no less. Learning Perl tought me to code. Sweet.

      --
      Stop intellectual property from infringing on me
  28. hallelujah! by schodackwm · · Score: 1

    ... holy wars, again.
    Kill for your favorite editor
    Take back the holy land of (insert fav language)
    Burn at stake (eq "flame") advocates of (insert OS)

    --
    [this sig has been trunca
  29. Supporting Perl is truely hell on Earth. by nicophonica · · Score: 1

    I remember debugging a Perl script that I was supporting. To paraphrase Truman Capote, I spent one day removing a backslash and the entire next day putting it back in. I never did fix the problem.

    1. Re:Supporting Perl is truely hell on Earth. by John+Bokma · · Score: 1

      "I remember debugging a Perl script that I was supporting. To paraphrase Truman Capote, I spent one day removing a backslash and the entire next day putting it back in. I never did fix the problem."
      Insufficient Perl skills?

  30. Re:First Use Python Post by abigor · · Score: 0, Troll

    No, it's a poor programmer who doesn't choose to use simpler, cleaner tools that do the exact same thing instead, and costs his/her employer money by not doing so. So who's the poor programmer here again?

    Or do you not write code for a living? My money is on "no".

  31. My Sig Says It All by frank_adrian314159 · · Score: 3, Funny

    You don't learn Perl - it gets absorbed through the blood-brain barrier. Leads to nasty flashbacks, too...

    --
    That is all.
  32. Learn to program by PhiznTRG · · Score: 2, Funny
    In my opinion, the best way to learn any language well is to see how others have used it to solve problems.

    Why of course! It worked for Bill Gates, it can work for you too!

    "The best way to prepare [to be a programmer] is to write programs, and to study great programs that other people have written. In my case, I went to the garbage cans at the Computer Science Center and fished out listings of their operating system."
    From Wikiquote.
    1. Re:Learn to program by Thud457 · · Score: 1

      Maybe little Billie should've stolen the "A" listings from the OS teacher's grading pile instead!

      --

      the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff

  33. WTF, Houston?!!! by Thud457 · · Score: 1

    This is supposed to convince me that learning Perl is a good idea?!!!

    --

    the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff

    1. Re:WTF, Houston?!!! by Anonymous Coward · · Score: 0
      That's up to you. Perl didn't invent the syntax, it borrowed it from the shell:
      #!/usr/bin/sh
      var1='fortune' # Assigns the string 'fortune'
      var2=`fortune` # Calls fortune, assigns result
      If you don't like it, feel free to change the delimiters:
      #!/usr/bin/perl
      my $f = qx(fortune); # Calls fortune
      So, if you're comfortable with the shell, use backticks. If you find backticks confusing, use qx. Perl gives you freedom of choice.
    2. Re:WTF, Houston?!!! by dotpl · · Score: 1

      your reply is stupid.

      you can't generalize from what you just read. There are concepts that you need to learn before jumping into the coding part.

      why my ($f) = `fortune` will give you the first line only? it's because, if you learned the language you will know that, the parenthesis () imply a list context, therefore, Perl will evaluate the RHS expression in list context, returning lines as list elements, so you can say:

      my ($a, $b, $c) = `fortune`;
      and you'll get the first three lines into these variables... similarly:

      my @lines = `fortune`;

      Like any spoken language, you can't just learn a couple of words and go argue about the grammar.

  34. Why is this modded offtopic? by Anonymous Coward · · Score: 0

    Why do posts which make an iota of sense get modded down?

  35. Why is this insightful? by Anonymous Coward · · Score: 0

    Why is the trivial response to the insightful grandparent marked insightful?

    It's shit like this that makes you want to stop reading Slashdot.

  36. Re:Quote by merlyn · · Score: 2, Informative

    False quote. Wheee.

  37. Perl Is Awesome by kmhebert · · Score: 1

    It really is. You can make it as readable or unreadable as you want. We use a ton of Perl scripts in our internal software; they handle customer service, repair issues, sales, provisioning, everything the company does actually. I like Perl because it's really easy to generate dynamic HTML with it. I avoid using $_ and other magic variables because, while they are useful when writing the program, they are a kick in the head when reading the program a month or two later. I have yet to come across a task that couldn't be implemented fairly easily in Perl. Plus, Perl has been around long enough that a ton of great packages are available for it; if I need to do a SOAP connection -- Perl supports it. Database interface? Perl handles it great. Time to talk to the serial port? Perl can do it! Honestly, to me the toughest part is figuring out what the user REALLY needs to get done with a particular piece of software; putting a Perl script together for it is the easy part. I have used other languages but for web-based software I'd recommend Perl (in our case using mod_perl on a Debian Linux server with a PostgreSQL back end) over just about anything. Your mileage may vary but I have to say that a lot of this hating on Perl is unfounded! Hate the player not the game folks!

    --
    Regular Meta Moderators are not more likely to get mod points.
    1. Re:Perl Is Awesome by John+Bokma · · Score: 1

      "I avoid using $_ and other magic variables "
      Sometimes you can make your code more readable by just using it, e.g. in ..... for @list; constructs. Or: for ( $var ) { s/..../.../g; s/..../...../g; ... } more readable compared to: $var =~ s/..../.../g; etc. avoiding language constructs "just because" is always a bad idea.

    2. Re:Perl Is Awesome by kmhebert · · Score: 1

      I always use the $var =~ s/..../.../g construct, it's more readable to me. And I also prefer to use something like foreach $real_variable_name_that_means_something (@list) to the $_ variable. Again, "your mileage may vary" but to me, at a quick glance, a named variable means something, $_ or other magicals requires mental parsing.

      --
      Regular Meta Moderators are not more likely to get mod points.
    3. Re:Perl Is Awesome by John+Bokma · · Score: 1
      "I always use the $var =~ s/..../.../g construct, it's more readable to me"

      I never use "always" or "never" constructions, for example if you want to do 1 s/// it can be more readable, but what if you want to do 3 in a row?

      for ($var) {
      s///;
      s///;
      s///;
      }

      other example:

      s/// for @array;

      " also prefer to use something like foreach $real_variable_name_that_means_something (@list)"

      I stopped using foreach and use for now. How I loop depend on what "I" do, sometimes I prefer

      for my $name ( @names ) {

      at other times:

      do something with $_ for @names;

      since many things use the $_ as default it can be even more readable to use the implicit $_

    4. Re:Perl Is Awesome by kmhebert · · Score: 1

      Heh, I always say always when I mean quite often.
      I do sometimes use $_, but I more often like to have every variable spelled out explicitly. And the reason is to give me a hint why I am looping on some array when I look at it a few months later. Maybe it's a bad habit, but it's never caused me any problems (that I know of). Is there a performance price for doing it one way versus another?

      --
      Regular Meta Moderators are not more likely to get mod points.
    5. Re:Perl Is Awesome by rs79 · · Score: 2, Funny

      " I have yet to come across a task that couldn't be implemented fairly easily in Perl."

      Write all of Unix from scratch on a PDP 11/20.

      I'll wait.

      --
      Need Mercedes parts ?
    6. Re:Perl Is Awesome by kmhebert · · Score: 1

      Ha, well, fairly easy right? One thing that makes it easier for me is I re-wrote the entire system from the bottom up in Perl so it would be easier to extend later on. For my tasks I have yet to come across anything that couldn't be done with Perl but of course I am extending my own codebase. When I get a task on my list to re-write Unix I would have to question the logic of doing it in the first place.

      --
      Regular Meta Moderators are not more likely to get mod points.
    7. Re:Perl Is Awesome by John+Bokma · · Score: 1
      "Heh, I always say always when I mean quite often."

      Like my girlfriend :-D.

      "Is there a performance price for doing it one way versus another?"

      That's most of the time the last thing to worry about. Pick what you consider the most readable. I use $_ but not as much as is possible. But sometimes using $_ implicitly looks better (to me, that is)

  38. About 'my ($f) = `fortune`;' by Shachaf · · Score: 4, Informative

    Read more about the issue here.

    1. Re:About 'my ($f) = `fortune`;' by wunderhorn1 · · Score: 1

      I remember that story... thanks for saving me the trouble of looking it up again.

      --
      Karma: Bored. (Thinking about resurrecting the "Anyone else is an imposter" joke.)
  39. Re:First Use Python Post by m50d · · Score: 1

    That's because English is a fucking mess, and should be abandoned to the scrapheap of history. I'm surprised you say that's the case with Latin though. Sure learning all the vocab takes time, but that's equivalent to learning the library in a language rather than the language. Understanding how to fit subjects and objects and verbs together, how to work out what ending to put on things, what's grammatical and what isn't took you more than 6 books? I'm surprised.

    --
    I am trolling
  40. Agreed, and Effective Perl Programming still great by Ars-Fartsica · · Score: 0

    This is the only book I recommend along with Programming Perl. There really is a lot of great stuff in there, and the book is short enough that you will actually read it. The Schwartzian Transform has appeared in my code many times and it wouldn't had I not read this book.

  41. If all languages were easily understood... by suitepotato · · Score: 1

    ...there would never have been anything but open source as everyone would be capable of writing any kind of code they wished any time they wanted. Of course, it wouldn't have been much worthwhile given it would largely have dealt with referring to libraries of nonsense code which embodied inane ideas like MustWatchSurvivor() and McDonaldsEveryNight(). Screwed if it was, screwed that it isn't.

    --
    If my grammar and spelling are off, I am [distracted/tired/careless] (take your pick)
  42. Learning Perl ... by Nohea · · Score: 0, Redundant

    After i read Learning Perl and doing test scripts, i felt like i was a real programmer in my gut (instead of just trying to "get it").

    Thanks for the best book on learning programming, Randal!

    1. Re:Learning Perl ... by rs79 · · Score: 1

      "After i read Learning Perl and doing test scripts, i felt like i was a real programmer in my gut"

      I had a reaction in my gut too. But not the same one you had. Fortuneately, since the creation of ICANN I've kept a bucket near my desk at all times.

      --
      Need Mercedes parts ?
  43. Thanks Randal by Ars-Fartsica · · Score: 1

    your articles over the years have really improved my perl coding, and there are many code samples you provided that made it practically verbatim into production code where i work.

  44. Reality: no one like inheriting code of any kind by Ars-Fartsica · · Score: 1

    Come on, you'd be in the same boat if you were inheriting someone's lisp or java or whatever. Ineriting code sucks! Everyone knows this. This is why good coders demand "new code" positions when they interview.

  45. Reading Perl code?-Blind leading blind. by Anonymous Coward · · Score: 0

    "I think Perl appeals to hackers who like to write. I think Perl flexes some of the same mental muscles that writing and speaking flex and therefore appeals to people who tend to think in language-centric ways. It also probably explains why the primary strength of this idiosyncratic, language-like programming tool is processing text and text-like patterns. It just appeals to people who are linguistically minded and was developed with language interpretation in mind."

    And yet we still can't get coders to comment their code, and write documentation.

    ---
    Ptags

  46. Re:First Use Python Post by WillAffleckUW · · Score: 1

    Or do you not write code for a living? My money is on "no".

    You'd be wrong.

    As to Python being "better" than Perl - it depends on what you want. Is English cleaner than other languages? No, yet everyone speaks English if they want to get things done, pretty much.

    --
    -- Tigger warning: This post may contain tiggers! --
  47. Its not the language... by psicode · · Score: 2, Insightful

    its the developer that writes unmaintainable code.
    TMTOWTDI and the Perl syntax have hardly anything to do with badly written code in Perl or any other language. Sure understanding an expressive language like Perl takes a bit more than learning a language like Java. But that does not mean that Java or [insert any language here] prevents you from writing ugly code. I am primarily working as a Java developer on mostly large projects and the amount of badly written code I have to deal with is simply frustrating. And most of it is written by "Senior" developers and design pattern aficionados!!!

    1. Re:Its not the language... by John+Bokma · · Score: 1

      Hear Hear. Also Perl has some constructs in the langauge that require one to use a library in for example Java. Many people complain about the regexp syntax. I have yet to find a language (not Perl related) that does it easier.

    2. Re:Its not the language... by Foolomon · · Score: 1

      Yeah, those design pattern aficionados need to be shot. [Rolls eyes]

      Everyone uses design patterns regardless of whether or not they explicitly know they are doing so. People who use design patterns effectively will write more maintainable code.

      If you don't understand why then maybe you should read a book on design patterns instead of Perl. :P

    3. Re:Its not the language... by Fahrenheit+450 · · Score: 1

      People who use design patterns effectively will write more maintainable code.

      Yawn... Insert obligatory response to someone touting the utility of design patterns here.

      --
      -30-
  48. Perl is not innocent in the hideous perl problem. by Anonymous Coward · · Score: 0

    The language is designed to be difficult to read. It allows you to do things far too many different ways, it is crammed full of "shortcuts" like @_ to make code as unreadable as possible, and it doesn't even support function arguments, making every frigging function require argument handling at the top. This is perl's fault, and although you can write code without @_isms, the fact that they are part of the language encourages them to be used. There is simply no reason for shortcuts and automagical variables with no letters in them.

  49. No, C and java have nothing to do with it. by Anonymous Coward · · Score: 0

    The important thing is not wether it would take you more time to understand a C or java version, its would it take you more time to understand a python or ruby or pike version. And in all cases the answer is no. There is no excuse for perl to suck as bad as it does, there are 3 perfectly good alternatives, that are all much easier to both write, and read. Perl needs to be put euthanized.

  50. Re:First Use Python Post by John+Bokma · · Score: 1

    Funny, I just read 2 Python Books (one was Dive into Python), and am convinced that I have to read at least another (the library reference) Maybe because I want to do some serious stuff with the language and reduce the number of wheel reinventions :-D.

  51. No, perl earned its hate. by Anonymous Coward · · Score: 0

    Just because you avoid using @_ and $_ and $#@)$(_ and all the other "helpful" automagical variables with no names doesn't mean they aren't there. If a language adds something, people will use it. There is no reason for this crap to exist, and that is most certain perl's fault.

    And I am sorry, but there was never any excuse to design a language where functions don't take arguments. This the stupidiest, most rediculous thing I have ever seen. function (arg1, arg2) is a whole lot nicer than having to validate the contents of an automagically argument array and then assign the contents of the array to arg1 and arg2.

    1. Re:No, perl earned its hate. by kmhebert · · Score: 1

      Yeah, that's one place where I use good old $_. I load the arguments into scalars at the beginning of the function and give them useful names, and in that situation doing
      ($customer_id, $payment_amount, $vendor) = $_;
      is usually pretty self-explanatory, in the context of the function.

      --
      Regular Meta Moderators are not more likely to get mod points.
  52. It isn't the language by Foolomon · · Score: 1

    <rant>

    It isn't the language: it's the programmers using the language that make Perl programs unreadable.

    That being said: there are a lot of mediocre programmers in the world who think that it is neat to use every feature of the language they are using. This leads to unreadable Perl / C / insert your favorite language programs.

    However, Perl does provide much much more than a yard of rope with which a company can hang itself by employing programmers without having the necessary controls in place (e.g. design / code reviews, etc.) to ensure that maintainable code is being produced.

    </rant>

  53. Re:First Use Python Post by Anonymous Coward · · Score: 0

    Mostly I agree, but the good thing about perl is that if you just want to fix a bunch of files, say, it's as simple as this:

    perl -p -i -e "s/\r//g" *.txt

    or whatever.

  54. Spoken with Reverence by pinkfalcon · · Score: 1


    Was I the only one that heard
    "You'd do it for Randall Scwartz"
    Townspeople with angelic chorus: "Raaandall Schwaartz".

    When I read that headline?

    after thirty years - the reference is meaningless, but the joke is still funny.
    (note to nitpickers yes I know the original is Randall Scott)

    --
    Real SUV's don't have cupholders
    It's 5:42 A.M., do you know where your stack pointer is?
    1. Re:Spoken with Reverence by Anonymous Coward · · Score: 0

      Actually, it was "Randolph Scott."

  55. Since I don't have mod points... by bloggins02 · · Score: 1

    (Score:$number, $adjective)

  56. It's easy! by fprog26 · · Score: 2, Insightful

    It's not difficult to read at all; however, you wrote it in backward perl syntax with implicit variables. It's easy. It prints a concatenated list of prime numbers between 2 and 100 with no delimiter.

    So, let's rewrite this program without implicit $_ variable, without && comparision and with a temporary variable.

    for my $number (2..100)
    {
    my $unary_string = (1 x $number);

    if ( $unary_string !~ m/^(11+)\1+$/ )
    {
    print $number;
    }
    }

    Which is quite readable now.

    For all numbers between 2 and 100. Take that number convert it into UNARY format. Now, if it doesn't match recursively the first set of ones (at least 2) with the trailling set of ones having the same number of ones (at least once).

    So basically the matching algorithm is like this:

    2 11 insufficient
    3 111 insufficient
    4 11 11 matched 4
    5 11 1 11 mismatch
    6 111 111 matched 6
    7 111 1 111 mismatch
    8 1111 1111 matched 8
    9 111 111 111 matched 9
    10 11111 11111 matched 10
    11 11111 1 11111 mismatch

    It seems to test for prime numbers...

    If it's not a non-prime number since no match is found it prints the number without any delimiter on stdout.

    Conclusion:

    If I was to write this script with this "algorithm", I would write it like this:

    #!/usr/bin/perl -w

    # Print prime numbers between 2 and 100 by converting it into unary format and by testing for matching multiple pairs of double ones or more.

    for (2..100)
    {
    my $unary_string = (1 x $_);

    print if ( $unary_string !~ m/^(11+)\1+$/ );
    }

    BTW, writing a program in C to test for prime number would be quite more complicated!
    Especially if you use this algorithm without a regexp library!

    Enjoy!

    Fred.

    - Long life to Perl!

    1. Re:It's easy! by vhold · · Score: 1

      "It prints a concatenated list of prime numbers between 2 and 100 with no delimiter."

      I'm only gunna correct that tiny little bit :) The -l command line option gave him implicit delimiter behavior with print.

  57. this one time by Anonymous Coward · · Score: 1, Funny

    Randall Schwartz came to a PDXLUG meeting and got kicked out by the owner of the coffee shop because he refused to pay a service charge for using his credit card to purchase a coffee.

    1. Re:this one time by Anonymous Coward · · Score: 1, Informative

      Well..... technically he got kicked out because he launched into an asinine rage about the service charge on his debit card. Also, about some coffe candies which has a mismarked price of ".03 Cents". Oh, and 'false advertising', and the coffee shop being 'the worst business in Portland'. (Comical due to the "Small Business of the Year" award just behind the cash register.) [But I don't really want to get all technical.]

  58. Re:Quote by Aldric · · Score: 0, Offtopic
    It depends on your background. If you spend a lot of time writing C/C++/Java then PHP is a whole lot more attractive than Perl. Because of the similar systax and structire of the language there is no need to spend time getting into a completely different mindset.

    Personally I have nothing against Perl, it's just that I spend about half my time writing server apps in C and the other half writing web apps to interface with them. It makes me more productive to be able to switch languages instantly.

  59. Backwards compatiblity always sucks... by Anonymous Coward · · Score: 0

    This is supposed to convince me that learning Perl is a good idea?!!!

    Well, one of the primary motivations for Perl was to replace shell scripts. It really shines at that. If you don't believe me, trying maintaining a 2,000 line shell script, and compare it to the equivalent perl script. I'll bet you'll take perl, because it's usually (a) simpler, and (b) more powerful.

    The backquotes were taken straight from shell scripting, in order to make it easier to port shell script to Perl. Perl kept the meaning the same, because changing it would have confused the target audience (shell programmers).

    The regular expression syntax is backwards compatible with sed for the same reasons, though Larry extended the regular expressions to have very useful things, such as matching on whitespace versus non-white spaces.

    Perl turned out to be astoundingly popular, and useful for many more things than shell scripting, though it's still good at that.

    Much of the ugly syntax was inherited. There are many ugly things about Perl syntax. But on the other hand, Perl works, works well, and generally gets the job done with little coding effort. If one puts in enough coding effort into making the code simple and expressive, then Perl is maintainable as well.

    If you don't, well, Perl will teach you more quickly than any other language why writing simple, expressive code is a good idea. Just try to maintain it six months later... :-)
    --
    AC

    1. Re:Backwards compatiblity always sucks... by putaro · · Score: 1

      If you don't, well, Perl will teach you more quickly than any other language why writing simple, expressive code is a good idea. Just try to maintain it six months later... :-)

      Quite true! Unfortunately it takes at least six months for the newbie programmer working in Perl to learn this lesson which allows a lot of time to leave a big trail of destruction.

    2. Re:Backwards compatiblity always sucks... by Anonymous Coward · · Score: 0

      Quite true! Unfortunately it takes at least six months for the newbie programmer working in Perl to learn this lesson which allows a lot of time to leave a big trail of destruction.

      This is one reason why it's nice to have senior programmers mentor the novices: it can teach the novices good style by example (assuming the senior codes have good style, that is), and the senior programmers get an idea of what the code they'll be refactoring in six months looks like. ;-) Call me cynical, but sometimes people just don't learn.

  60. Perl can handle code larger than one page, thanks by Anonymous Coward · · Score: 0

    Believe it or not, there are "subroutines" in Perl for things that take more than one page of code!

    -- someone who has ~150k lines of production perl (+ smaller amounts of Java and VB) bringing in ~$1m/year (additional hint: "perl modules")

  61. Load Balancing? by Anonymous Coward · · Score: 0

    "light-weight load balancer"

    This phrase seems wrong to me in so many ways. How can a load balancer have weight? It either does, or doesn't...with varying levels of efficiency. Is the load itself light weight? If so, why bother load balancing at all?

  62. I like Perl by Cyno · · Score: 3, Insightful

    I wrote a Perl script yesterday with a bad algorithm using 2 lists. Ran all night and was still running when I got into the office this morning, and it didn't spit out any relevant data.

    Rewrote the script using 2 hashes in about 15 minutes. Completed in less than a minute with all the info I was looking for.

    So, um, I think an evaluation of most programming languages is more dependant on the programmers than the language itself. Sure some languages lack the proper data types or features, but any modern/complete language is capable of being readable and resource efficient if the programmer knows what they are doing. IMO, of course. I'm not a developer.

  63. Re:First Use Python Post by Anonymous Coward · · Score: 0

    > That's because English is a fucking mess, and should be abandoned to the scrapheap of history. I'm surprised you say that's the case with Latin though.

    Because even the Romans hated Latin. They ended up writing all their plays in Greek.

  64. English module by sbszine · · Score: 1

    I avoid using $_ and other magic variables because, while they are useful when writing the program, they are a kick in the head when reading the program a month or two later.

    Have you tried the built-in English module? Just add this line to your script:

    use English;

    Then you get verbose aliases for the magic variables. So $. becomes $INPUT_LINE_NUMBER, $" becomes $LIST_SEPARATOR, etc.

    A complete list of the aliases can be found here.

    --

    Vino, gyno, and techno -Bruce Sterling

  65. Explicit programming is often better by r6144 · · Score: 1

    Sometimes I even wish C would use different operators for signed, unsigned and floating-point multiplication (among others). In reality I have to use many typecasts to tell the language what I really mean, which is unclear and error-prone.

    1. Re:Explicit programming is often better by rs79 · · Score: 1

      "Sometimes I even wish C would use different operators for signed, unsigned and floating-point multiplication (among others). In reality I have to use many typecasts to tell the language what I really mean, which is unclear and error-prone"

      What you want is called FORTRAN. Never loose sight of the fact C was, is and will always be a shorthand for Assembly. Even Dennis Ritchie has said he'd used FORTRAN for matrix inversion or dealing with 80 column card images. Don't laugh these data structures still exist even if the cards no longer do.

      --
      Need Mercedes parts ?
  66. "How Others Have Used It"?!? by adavies42 · · Score: 1
    In my opinion, the best way to learn any language well is to see how others have used it to solve problems.

    In the case of perl, this is exactly the wrong way to do it!

    --
    Media that can be recorded and distributed can be recorded and distributed.
    -kfg
    1. Re:"How Others Have Used It"?!? by KnightStalker · · Score: 1

      In any language, you obviously shouldn't look at bad examples. It may be true that Visual Basic is the only language with more bad examples than Perl, but there is plenty of good Perl code out there to read through -- most of what's in CPAN for example.

      --
      * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  67. Why I modded you down... by jjn1056 · · Score: 1


    I don't like to mod someone down without saying why.

    Lot's of responses on Slashdot are predictable. Mention BSD and you'll get 20 posts about how it's dying, etc. Mention Perl and you will get quite a few posts complaining about how Perl is unreadable or not suited for 'real' programming.

    Then you will get a bunch of people saying Perl code can be good or bad depending on the programmer who wrote the code.

    It's kind of silly really, and I usually just ignore it. I would have ignored your vulger post as well, but someone modded it as 'funny' I disagree with your statement being funny.

    So you can say I am not modding your post, but I am modding the person who thought such a vulgar comment, of which literally dozens of similar ones exists, deserved to be modded as funny.

    Maybe the first time it was a little funny, but at this point I don't think it's funny unless it's at least a bit clever. This post is just an AC saying what's been said over and over already.

    BTW, I don't object to this simply because it's vulgar. I enjoy watching "South Park", which is often extremely vulgar, but it is also fresh and clever. That is why it's so funny to me.

    So unless you got a new angle on 'Perl Code is Trash', I really don't think it should be modded up as informative, funny or anything.

    Anyway, you should prove your point with a telling example of Perl obscurity. It's not like such a thing would be hard to find :)

    --
    Peace, or Not?
  68. Nonsense! by anandamide · · Score: 1

    The principles of writing clean software apply whether the program is 1 page or 100. There is *nothing* preventing the creation of large, maintainable programs in perl except the ignorance and/or laziness of the programmer.
    You can write unstructured, ill-formatted, ill-documented slop in any language. A lot of people just think 'perl: quick and dirty solutions. Don't bother to use good craftmanship.' Guess what they end up with?
    I've been a professional perl programmer for years, and I have no trouble understanding and maintaining my old code. Thousands and thousands of lines of code.

    1. Re:Nonsense! by m50d · · Score: 1

      No, nothing prevents it, but you have to make more effort. Perl lets you leave off function parameters, use some neat one liners to compress loops, and trust the defaults for lots of things, encouraging you to be lazy. Sure, you can keep writing verbosely to make things understandable, but it takes a lot of willpower to do so when there are all those shortcuts available. You can write readable code in any language. And you can write unreadable code in any language. But it's easier to write unreadable code in perl.

      --
      I am trolling
  69. huh? by rs79 · · Score: 1

    Forget Perl, I can't even understand your presumably English language posting.

    Forget to close a tag did we?

    (insert cheap shot about "typical Perl programmers lack of ability to write anything coherantly.")

    --
    Need Mercedes parts ?
  70. Garbage in garbage out by rs79 · · Score: 1

    "Why of course! It worked for Bill Gates, it can work for you too!

    "The best way to prepare [to be a programmer] is to write programs, and to study great programs that other people have written. In my case, I went to the garbage cans at the Computer Science Center and fished out listings of their operating system."
    "

    This explains nearly everything. Code reuse is a good thing but...

    Dear Bill;
    That code was in the garbage can for a reason. The good stuff was in nice binders neatly placed on peoples shelves.

    --
    Need Mercedes parts ?
  71. Re:Uhhh.... by rs79 · · Score: 1

    "When I was a tad, we didn't have all these fancy newfangled languages. We were so poor, we were glad to have two bits to rub together. We had to make everything from bits. Why, I remember one time, I wanted a dog, so I made one from bits. He was a little buggy, but he was the best damn dog a boy from the bit-mill ever had. I wore my fingers to bloody nubs flicking toggle switches on that front panel. But I learned the value of hard work and perseverence. Not like you youngsters these days with your nancy keeyboards and you poofter mice."

    You had bits? Why when we were kids we could only dream of bits. We had scraps of paper and fountain pens. But we were happy.

    --
    Need Mercedes parts ?
  72. your so-called example just proves him right by Anonymous Coward · · Score: 0

    your code is not any easier to maintain than C code.

    if anything your example shows how perl is broken and needs to use bubblegum and bailing wire to provide basic functionality of other languages.

    but go ahead and ignore the fact that perl6 adds a switch statement because they realised that they (and you) were completely and utterly wrong. larry wall knows more about perl than you do, and he added the switch statement to perl6 syntax. pwned.

  73. On Perl by Anonymous Coward · · Score: 0

    There are three serious problems with Perl

    1. Magic. Filehandles are magic, for example, and consequently possess magical properties that don't map cleanly onto understanding what's 'inside' a variable. In other languages a variable is either (a) a simple scalar or (b) an object reference, but in perl there are 'magic' things like filehandles that just don't map cleanly.

    2. Syntax. e.g the way an inbuilt 'function' like match or split (or are they statements? - they have implicit side effects, too) needs that weird tilde 'operator' to assign its output somewhere other than the default $_. That's disgusting

    3. Compilation. Because almost any weird combination of metacharacters is probably legal perl, the compiler will often choke a LONG... way away from the originating error e.g missing piece of punctuation. This causes considerable head scratching.

    Also

    I think the metacharacter idea to determine variable type is flawed. It makes perl very hard to read because the human brain just doesn't handle this stuff, and soon the whole thing just blurs into line noise. The idea in modern languages is that if you don't know what variable 'aVar' is, you use the IDE features to automatically jump to the declaration, or auto-complete to immediately see what you're dealing with. So the need for $f and @a assumes your IDE is a text editor. Sorry, but the world has moved on!.

  74. Re:First Use Python Post by Anonymous Coward · · Score: 0

    Isn't perl a bit heavyweight for that kind of stuff, as opposed to a bit of shell and sed?

  75. Re:Perl can handle code larger than one page, than by m50d · · Score: 1

    Yeah, perl modules are a way to deal with it, but there's only so much you can put into a module. As for subroutines, you still need to be able to see and understand the program as a whole. It would take a very disciplined programmer to make a program modular enough that you could maintain it by simply looking at the subroutines in isolation.

    --
    I am trolling
  76. Is it just me... by AnxiousMoFo · · Score: 1

    ... or is that the most ass-hat way to discover primes ever?

    A C program (and a sane Perl script) would be more complicated in that it would require more lines of code, but it would require effort to produce an algorithm which is less efficient and less obfuscated than this one.

    This has nothing to do with Perl as a language, and everything to do with irritation at people who code using pointlessly clever algorithms like that one.

  77. Bad joke by BorgCopyeditor · · Score: 1

    "Programming perl" = perldoc perlrun?

    --
    Shop as usual. And avoid panic buying.