3 ms·
Notably missing from the 5 points he makes at the start of the article: Perl's regexes (unlike python and a swath of other languages) are first class citizens
by ur-whale 4y ago
Notably missing from the 5 points he makes at the start of the article:
Perl's regexes (unlike python and a swath of other languages) are first class citizens in the language (and not some effing library you have to import, along with its clunky API).
To wit:
PERL:
$x = $1 if(/^Line_start[ \t]*([0-9]+)/);
PYTHON:
import re
m = re.match(r'^Line_start[ \t]*([0-9]+)/, line)
if m:
x = m.group(1)
The latter is painful.
This is the only reason that still makes me sometimes pick Perl over python when I need to slap together a quick and dirty run-once script to chew thru a big pile of data.
Other than that, as much as I've used Perl over the years and found it extremely useful back in the day (coz it was the best there was at the time), it is a horrible language by modern standards ($ to identify variables, having to tell the compiler that an expr is at an end with a ';', ugh), and it is time to let it Rest In Peace.
- humanrebar 4y agoThe problem is that outside of very trivial or temporary situations, regexes should be named and tested. Especially for scripts that tend to be written, deployed indefinitely, and mostly ignored. One you have a name and a design where you can test the boundaries of that regex without, say, downloading large files or rearranging the filesystem, you aren't really buying all that much by avoiding some extra library boilerplate. But I'll admit that native support for regex comes in handy for throwaway scripts.