disclaimer: i was drunk when i wrote this

i like perl

it's a powerful language for small scripts. i often say jokingly that perl oneliners are equivalent to 200 lines of java.

but seriously, it's very expressive.

why?

people often ask me why i like perl.

i love python, and i love writing shell oneliners. it's just that neither are good enough for the stuff i've been doing.

the python point of view

oneliners from the shell don't exist.

python -c "import sys, re; print re.findall('[a-z]+', sys.stdin.read())"

73 chars long and barely does anything useful.

lambdas are a joke, with only one expression in them

to do more than that in an oneliner you have discard half of the structures and everything that is considered a "statement", only to find yourself using shortcircuit'd boolean operators in horrible ways.

all the beauty of the language is gone when you use it like that.

the shell script point of view

the beauty of the language never existed to begin with. spawning processes needlessly doesn't matter, forks are cheap, pipelines are cheap too.

but worse is better.

nothing is complex, there's just a bunch of minimal tools that do simple stuff

the most frequently used tools tend to be grep, sed, and some awk. i focused on sed mostly.

sed -n '1h;1!H;${;g;s/\."\?\n,//g;p;}' inputfile

this is the "multiline sed hack". uses some relatively uncommon sed commands to handle "hold buffers" so the whole file gets read into memory, so you can work over all of it.

it's a weird hack. the kind of hack that makes you wonder if you're doing things right.

there must be something better, right?

perl

perl is the best of both worlds.

it fills the gap between "properly structured object oriented python code" and "shitty bash script"

it lets you do a lot with little code

flaws

perl is not perfect. most people hate it for a reason. i used to hate it too. it's just that i've realized that for the stuff i do, it has more benefits than downsides.

i wouldn't use it to build anything with >1000 lines of code, that's just not where perl is good at.

it doesn't take a lot of effort to see those flaws. they are right in the introductory documentation, sometimes even lampshaded by the writer.

but i didn't find it too hard to see those flaws in a positive light. in fact, i find them 'charming'.