▲ | franticgecko3 2 days ago | ||||||||||||||||||||||||||||||||||
I've started learning (in 2025!) and using Perl lately as shell++ It's extremely stable, installed almost everywhere, and has much fewer insane idosyncrasies than shell. I can write some Perl and confidently hand it to a colleague where it will almost certainly work on their machine. It's a shame it's so dead, for a scripting language there's nothing else that ticks the same boxes. I would never write systems software with it, of course | |||||||||||||||||||||||||||||||||||
▲ | andrewl-hn 2 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
My go-to use case for modern Perl is to be the default program instead of sed. Sed regex support is abysmal and the same command line flags behave differently between BSD (and macOS) and GNU versions, in particular the `-i` for doing replacements - the number one use case for the program. So, this means that many shell one-liners and small scripts don't really work the same way on macOS and on Linux, and it's pretty annoying. Perl is straight up better. You need to remember one word: pie - for it's command line options, and now you can do:
First of all, it woks the same way across platforms.Second, you get all sorts of goodies: named capture groups, lookahead and lookbehind matching, unicode, you can write multiline regexes using extended syntax if you do something complicated. And finally, if your shell script needs some logic: functions, ifs, or loops, Perl is straight up better than Bash. Some of you will say "I'll do it in Python", and I agree. But if your script is mostly calling other tools like git, find, make, etc, then Perl like Bash can just call them in backticks instead of wrapping things into arrays and strings. It just reads better. BTW Ruby can do it, too, so it's another good option. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
▲ | tasty_freeze 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
At my work we use perl extensively for utility scripts and such. In the past few years there has been a push to write new scripts in python, but I don't really see the point. It has most of the same drawbacks that perl has: 30x slower than a compiled language and dynamic typing. We have many scripts that range from 5.8 to 5.36 and everything in between. 5.8 is 20 years old. Someone did a search & replace on the shebang lines to move all the older ones to 5.20 (why they picked that one, I don't know) and everything just continued to work. I prefer perl over python. turn on use strict, use warnings FATAL => 'all' and use modern function signatures. Perl is still great for its purpose. | |||||||||||||||||||||||||||||||||||
▲ | mmphosis 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
It's stable, installed everywhere, and I use programs written in Perl like when building Linux From Scratch. I haven't written in Perl since the 1990s. I do read code written in Perl and Raku, and I am often impressed by how succinct the code can be. | |||||||||||||||||||||||||||||||||||
▲ | superkuh 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
>It's extremely stable, ... It's a shame it's so dead, The former is the consequence of the later. Popularity kills stability. Perl is the ultimate sysadmin language because it's so portable and never changes. We really lucked out with the Raku thing driving people away to python. Because of it my perl scripts I wrote in 2003 run on perl system interpreter today and the vast majority of my perl written today would run on a 2006 perl interpreter (some functions missing in some libs in troublemakers like Gtk bindings, etc), but it's generally very good. These days with python you can't even run any random script written today on your system python from today. You have to set up an entire separate python for every script. And don't even think about trying to run a python script from 2006. That's what popularity does: fracture. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
▲ | Romario77 2 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
> for a scripting language there's nothing else that ticks the same boxes I think Python ticks almost all the same boxes (and is much better designed in my opinion). | |||||||||||||||||||||||||||||||||||
|