# Perl help

**URL:** <https://boards.straightdope.com/t/perl-help/823256>\
**Category:** Factual Questions\
**Created:** [October 20, 2018, 7:05pm UTC](https://boards.straightdope.com/t/perl-help/823256 "2018-10-20T19:05:14Z")\
**Posts on this page:** 16\
**Page:** 4

<div class="post-metadata">

**Author:** ![scabpicker](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/scabpicker/32/8268_2.png) [@scabpicker](https://boards.straightdope.com/u/scabpicker)\
**Post date:** [October 22, 2018, 12:23am UTC](https://boards.straightdope.com/t/perl-help/823256/61 "2018-10-22T00:23:08Z")

</div>

> [@leahcim](#):
>
> Python’s “Pythonicness” ia specifically a reaction to Perl’s free-formed-ness. Having a whole bunch of equivalent ways to do the same thing made for some incredibly hard-to-read perl code, since different programmers would express the same intent in radically different ways. Python’s strictness meant that intent was easy to infer from syntax.

Yeah, if I have one argument against Perl for this job, it’s that it’s the most frustrating language to learn from other’s examples, due to the many ways to achieve the same thing through different syntax. It also makes fixing others’ Perl a pain in the ass sometimes (“What the hell does _that_ operator do?”), but that doesn’t really apply here.

> [@leahcim](#):
>
> This is, I think, overstated. Perl had its heyday with CGI scripts in the 90s/early 2000s, and while there are probably plenty of hoary old CGI scripts holding together important things, they are almost extinct for any new work.

I’m not sure it’s overstated. I’ve monkeyed with other people’s Perl CGI code that was from a project created this decade, and written a few projects from scratch in it in that time. PHP, Python and a host of other languages have definitely made it less prevalent in that role, but it’s not dead in CGI, either.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [October 22, 2018, 12:39am UTC](https://boards.straightdope.com/t/perl-help/823256/62 "2018-10-22T00:39:53Z")

</div>

Python and Perl 5 are exactly the same language. They just have some superficial differences in syntax and culture.

ETA: I should take that back. There is one important difference: Perl does lexical closures correctly.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [October 22, 2018, 2:05am UTC](https://boards.straightdope.com/t/perl-help/823256/63 "2018-10-22T02:05:00Z")

</div>

Heh. Now [this guy](http://norvig.com/python-lisp.html) starts by claiming Python is basically Lisp with different syntax 🙂

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [October 22, 2018, 3:49am UTC](https://boards.straightdope.com/t/perl-help/823256/64 "2018-10-22T03:49:50Z")

</div>

Everything is Lisp with different syntax, because Lisp is so generalized that it is actually completely useless for accomplishing tasks.

---

<div class="post-metadata">

**Author:** ![Ashtura](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ashtura/32/2963_2.png) [@Ashtura](https://boards.straightdope.com/u/Ashtura)\
**Post date:** [October 22, 2018, 6:46am UTC](https://boards.straightdope.com/t/perl-help/823256/65 "2018-10-22T06:46:02Z")

</div>

> [@](#):
>
> I want to learn Perl so that I can convert Easytrieve into something free and modern.

I had to check the time stamp of this thread, as I thought it was a zombie thread from the 90s. What??

---

<div class="post-metadata">

**Author:** ![ticker](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@ticker](https://boards.straightdope.com/u/ticker)\
**Post date:** [October 22, 2018, 7:06am UTC](https://boards.straightdope.com/t/perl-help/823256/66 "2018-10-22T07:06:46Z")

</div>

> [@friedo](#):
>
> [Atom](https://atom.io) is an excellent free MacOS text editor for programming. I highly recommend trying it out if editing code via terminal applications is overwhelming for you.

I concur with Atom being an excellent choice. I have never used Perl so I decided to have a go with the OP’s “Hello, World” just for kicks. Atom instantly recognized I was writing in Perl and just did all the right things.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [October 22, 2018, 7:23am UTC](https://boards.straightdope.com/t/perl-help/823256/67 "2018-10-22T07:23:32Z")

</div>

> [@Ashtura](#):
>
> I had to check the time stamp of this thread, as I thought it was a zombie thread from the 90s. What??

I’ve been writing primarily Perl for a living for over 20 years. The language has evolved tremendously, though it’s not as popular as it once was.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [October 22, 2018, 9:25am UTC](https://boards.straightdope.com/t/perl-help/823256/68 "2018-10-22T09:25:35Z")

</div>

> [@friedo](#):
>
> Lisp is so generalized that it is actually completely useless for accomplishing tasks.

I’m pretty sure AutoCAD’s marketshare would disagree with you, were it not too big to notice your existence.

Anyway, this whole thread reminds me of something Zed Shaw once wrote: [_Early vs Beginning Coders_](https://zedshaw.com/2015/06/16/early-vs-beginning-coders/):

> [@](#):
>
> When I was working on Learn Python The Hard Way I was frustrated by how often I’d have to explain that the book is for a **total** beginner. The problem is that most of the technology world considers someone with about two programming languages under their belt a “beginner”, but learning two programming language would take you about 4-6 months. After 6 months you can’t really say someone is a beginner since, well, 6 months later is not the beginning. The beginning of something is…I mean why do I have to say this…at the **beginning**. Not 6 months later.
> 
> [snip]
> 
> What I propose is we have **beginning coders** and **early coders**. I got this idea from a painting teacher who kept referring to students who had never painted as “beginners”, but those who had painted for about one class as “early”. The reasoning is that you need a way to differentiate people who don’t know a damn thing vs. people who know the basics but just simply suck at them. Teaching a beginner is very different from teaching someone who’s already been doing it for a bit and just needs more training.
> 
> For example, a beginning coder doesn’t know how to type the | (pipe) character. They don’t even know it’s called a “pipe”. I’m not joking about this. Professionals actually don’t believe me when I tell them this, but it’s true. Beginners have zero experience so simple things like making a text file, opening terminal, and even the idea that you can type words at a computer and it will do stuff, are simply unknown to them. To teach a beginner effectively requires this level of information slowly fed to them in reasonable chunks.

Anyway, and he doesn’t mention this in his little essay/rant, his method for teaching **beginning coders** is to have them literally type _exactly what he has in the book_ into a shell or text editor, and, yes, he _tells them which editor to use_.

He’s opinionated to the point of being dictatorial, but seeing what the OP was going through in the first page of this thread, I can understand why: Someone who’s never done anything before in a given field has no opinions, because they have no basis for comparison. They need to copy the opinions of others if they want to get anything done, and they can branch out later if they see something which appeals to them _after_ they have enough knowledge to know _why_ it appeals to them.

---

<div class="post-metadata">

**Author:** ![Ashtura](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ashtura/32/2963_2.png) [@Ashtura](https://boards.straightdope.com/u/Ashtura)\
**Post date:** [October 22, 2018, 4:59pm UTC](https://boards.straightdope.com/t/perl-help/823256/69 "2018-10-22T16:59:07Z")

</div>

> [@friedo](#):
>
> I’ve been writing primarily Perl for a living for over 20 years. The language has evolved tremendously, though it’s not as popular as it once was.

Obviously there are still developers doing Perl, but I had to switch when most of the jobs were covering legacy systems. How boring.

---

<div class="post-metadata">

**Author:** ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)\
**Post date:** [October 22, 2018, 5:31pm UTC](https://boards.straightdope.com/t/perl-help/823256/70 "2018-10-22T17:31:48Z")

</div>

> [@friedo](#):
>
> I’ve been writing primarily Perl for a living for over 20 years. The language has evolved tremendously, though it’s not as popular as it once was.

From \*[http://www.cgi101.com/book/intro.html\*:](http://www.cgi101.com/book/intro.html*:)

\*Author’s note, Feb 2017:  
When this book was first published, CGI and Perl was one of the few options for adding dynamic content to a website. These days it’s largely been left behind as newer languages have become popular. Learning Perl/CGI probably won’t get you a job, because hardly anyone uses it anymore. But if you’re a tinkerer — a do-it-yourselfer who wants to learn to code and customize your website — this could be for you.

Perl is an incredibly useful language; I think of it as my secret super-power. 😉 It’s awesome for reading, writing, parsing, reformatting, and summarizing text files, databases, log files, raw data… you name it. It’s useful not just for CGI scripts but for any kind of automated scripting or data processing. And it’s available on most every Unix system, from your desktop Mac to high end cloud servers to the tiny Raspberry Pi. There’s also a huge library of free, pre-written modules for Perl, which you can download from CPAN.

Learning CGI/Perl may not get you many points on your resume, but it’s easy to learn, and you may find it a valuable tool to have in your developer’s toolkit.\*

As I’ve said previously and in the first thread where the o.p. was originally asking the question, if he were interested in really becoming a programmer, I’d recommend start with Python (or Ruby, although my preference is for Python and it is the language that seems to be more broadly in favor now for web framework application development despite the earlier popularity of Ruby On Rails), but learning to write good Python code means learning the appropriate programming paradigms and how to correctly format and write code. Perl doesn’t really come with any of that overhead, and if it suffers in terms of readability from developer to developer for its lack of standardization in how to write code, it also makes it easy for someone to pick up and use because they can play around with it and figure out what makes sense to them without worrying too much about the “right” way to do things. And it is purpose designed for text munging with regex functionality built right into the core language. For the o.p., who doesn’t really seem that interested in becoming a general programmer but just wants to solve this particular problem of finding a replacement for Easytrieve.

I had a good laugh over the comment that “Python and Perl 5 are exactly the same language,” and even more with “Everything is Lisp with a different syntax”. It’s actually kind of true; once you understand the mindset of a certain type of programming (declarative functional, imperative, object oriented, et cetera) as long as a language supports that learning it is really more like learning a dialect of a new language rather than having to learn an entirely new skillset. Being a programmer isn’t really the same thing as being a computer scientist–the former is learning the practical applications of programming while the latter is studying more theoretical or abstract methods behind the concept of computing–but a good programmer is actually language agnostic in terms of being able to write good code with some understanding of the particulars of the language. Except for Java–I’ll maintain that nobody can write good code in Java because it is purpose-designed to generate algorithmic shit. The JVM was a great idea, but he Java language is crap that takes the worst ideas from C++ and then guts all the functionality.

Stranger

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [October 22, 2018, 6:07pm UTC](https://boards.straightdope.com/t/perl-help/823256/71 "2018-10-22T18:07:03Z")

</div>

Honestly, a lot of the shit Perl gets comes from the fact it has the _really, really good_ regular expressions, and regular expressions are a _really, really good_ way to parse text once you have some degree of mastery. They’re traditionally very terse and uncommented, even though Perl supports multi-line regular expressions with comments, but to someone who knows how to read them, they can save pages of code every single time they’re used.

Perl is also used to solve gungy problems, problems like parsing undocumented or otherwise unclean file formats, where there is no clean solution, just working solutions, and the most efficient solution is likely one with a lot of regular expressions.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [October 22, 2018, 6:17pm UTC](https://boards.straightdope.com/t/perl-help/823256/72 "2018-10-22T18:17:56Z")

</div>

I mentioned in the other thread that Perl regular expressions have been ported to Python and other languages. Presumably this was done because they are awesome, not because they suck. I also independently have it on good authority that the Perl regular expressions library was implemented by computer scientists who knew what they were doing, and uses optimal or efficient algorithms. So Perl may get shit, but not because of regular expressions.

---

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [October 22, 2018, 9:22pm UTC](https://boards.straightdope.com/t/perl-help/823256/73 "2018-10-22T21:22:36Z")

</div>

> [@Ashtura](#):
>
> Obviously there are still developers doing Perl, but I had to switch when most of the jobs were covering legacy systems. How boring.

Legacy=anything currently running in production/live 🙂  
My brother’s kids are in high school and doing programming etc. I mentioned something about how we just standardized on Python (got rid of Perl, Powershell, old VB stuff, etc. etc.), and their response was “Python’s an ancient language, we don’t want to use anything that old.”

I had a good laugh.

---

<div class="post-metadata">

**Author:** ![Francis\_Vaughan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/francis_vaughan/32/3093_2.png) [@Francis\_Vaughan](https://boards.straightdope.com/u/Francis_Vaughan)\
**Post date:** [October 22, 2018, 10:03pm UTC](https://boards.straightdope.com/t/perl-help/823256/74 "2018-10-22T22:03:19Z")

</div>

The fact that Perl’s regexp language was used in Python was one reason I was suggesting Python was a better choice. You get the really good bit of Perl, and none of the cruft.

Doing a flexible fast and easy to use regexp is not easy. The first job I had after graduation had me design and write one. Just getting my head around the needed transforms to get to NFA’s, DFA’s (non-deterministic and deterministic finite state automata) took ages, and Aho and Ullman was my constant companion for weeks. Working through the semantics of lazy and eager matching in a manner that is useful is not trivial either, as well as sub-match extraction. Great fun, and left me with a lasting admiration for people like Henry Spencer - who later wrote the regex library as well as the theory guys. This stuff isn’t easy, and my efforts, although going into production in a locally written text editor, was never fully right - for reasons that I only really understand now.

---

<div class="post-metadata">

**Author:** ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)\
**Post date:** [October 22, 2018, 10:10pm UTC](https://boards.straightdope.com/t/perl-help/823256/75 "2018-10-22T22:10:47Z")

</div>

> [@Francis\_Vaughan](#):
>
> The fact that Perl’s regexp language was used in Python was one reason I was suggesting Python was a better choice. You get the really good bit of Perl, and none of the cruft.

You also get the verbosity of Python and the need to import external libraries and call them like functions versus essentially calling imperative commands in Perl. Perl is not a great choice for many things but its strengths in text munging (not just the regex but how it handles strings in general) is powerful, and you can learn to use that functionality in minutes without spending the time on how to write structured programs and define functions.

> [@Francis\_Vaughan](#):
>
> Doing a flexible fast and easy to use regexp is not easy. The first job I had after graduation had me design and write one. Just getting my head around the needed transforms to get to NFA’s, DFA’s (non-deterministic and deterministic finite state automata) took ages, and Aho and Ullman was my constant companion for weeks. Working through the semantics of lazy and eager matching in a manner that is useful is not trivial either, as well as sub-match extraction. Great fun, and left me with a lasting admiration for people like Henry Spencer - who later wrote the regex library as well as the theory guys. This stuff isn’t easy, and my efforts, although going into production in a locally written text editor, was never fully right - for reasons that I only really understand now.

Regexs are impressive, and in many ways the are a precursor to more complex lexigraphical parsing of natural language. The more I used regex, the more I thought about how we actually interpret written language and how you can recognize words in context even when they are misspelled or missing letters. I think there are probably some deeper insights to be gained by understanding something like regex, even if it isn’t strictly how the language cortices of the brain work because their is something in the pattern matching that at least looks like cognitive prediction in written language interpretation.

Stranger

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [October 22, 2018, 10:31pm UTC](https://boards.straightdope.com/t/perl-help/823256/76 "2018-10-22T22:31:30Z")

</div>

> [@Francis\_Vaughan](#):
>
> The fact that Perl’s regexp language was used in Python was one reason I was suggesting Python was a better choice. You get the really good bit of Perl, and none of the cruft.

Python gets you the part of Perl’s regular expression language which is easy to port to Python. You don’t get the fact you can embed Perl code in Perl regular expressions, which, like so much of Perl, is something you should only use rarely but which can make programs much more expressive in the hands of an expert.

And Perl is an expert’s language, in that it is full of ways to make code adhere to different standards: Shorter, easier to read as English, more functional, more OO, and so on. It leaves the decision of what “better” means to the programmer, much like Common Lisp. Python, on the other hand, follows Scheme in deciding that there is one Pythonic way, and “better”, in Python, necessarily means More Pythonic, more in line with the single style the language tries to enforce in every case.

They’re both useful. They’re both practical. (Well, Python doesn’t have anything like the perl interpreter’s -p and -n command-line options to facilitate one-liners, but Python doesn’t really _do_ one-liners.) They’re both potentially readable or potentially unreadable. They just approach “friendly” from different directions.

[Previous page](https://boards.straightdope.com/t/perl-help/823256.md?page=3)
