4 ms·
Perl is cool but it's got a hell of a lot of cryptic operators for its syntax. They make sense after you learn them but for beginners it's clear why python gets
by jamal-kumar 5y ago
Perl is cool but it's got a hell of a lot of cryptic operators for its syntax. They make sense after you learn them but for beginners it's clear why python gets picked up way easier. They're not having to think in symbols and stuff, it just looks more like a list of instructions rather than a mess of dollar signs and 'my' (my what? just not retrospectively intuitive...)
That said I like perl (And lately, awk/sed) a lot more for things that python is just SLOW at. Plus for systems-level scripts, considering that most linux/BSD installs you encounter on anything at all will have perl installed, let's say you encounter a router or something like that you need to work on somehow internally -- Do you even have room for another interpreter on there? Better be at least initiated in using perl if you want to hack on that. I've also recently found it really useful for rescuing an ancient database file format from the 1980s which was super handy considering other tools choked on it.
- ChrisMarshallNY 5y ago> Plus for systems-level scripts I still tend to use it for that.
- jamal-kumar 5y agoConversely, there's also so many things you can do in a perl (or awk/sed if performance or avoiding malloc by streaming data is necessary) oneliner in a shell script if you know some cool tricks. It's crazy how many resources are thrown into stuff like hadoop (literal ironic elephant logo) clusters to process CSV when dinky tools older than I am can zip through that data 1000x faster just by keeping it in the processor cache on my laptop https://learnbyexample.github.io/learn_perl_oneliners/cover.html https://learnbyexample.github.io/learn_perl_oneliners/cover....
- qalmakka 5y agoPerl might be weird, but it's logic and it makes sense. References are not automagical, but explicit, so you don't get an inconsistent function calling model. If you call a sub like `something(%h)`, it will get a copy of the hash. If you use `something(\%h)` the sub will receive a reference to access the hash instead. This is way better than Python or Java where everything is "pass-by-reference" until it isn't, and the fact a function won't modify the arguments you passed to it is basically a gentleman's agreement. Perl is complex, but it is also rewarding when you use it for those tasks it's good at (like gluing code together and text processing).
- datameta 5y agoIve only used Perl for one story at work but I don't fully grok yet why we $ a @ or a % Getting a hash passed by ref to a sub was a true syntactic challenge that I haven't experienced in a different language. Have to say though, using regex in Perl is chef's kiss
- qalmakka 5y agoBecause an array is a list of scalar, and an hash a map of scalars. If you want to access a scalar inside the list, you write $a[1], which means "the scalar at the first position of list @a". If it was @a[1] it would have been inconsistent, because then a @ expression would have returned a scalar and not a list.