6 ms·
I’ve had very limited contact with Perl, but for scripting purposes it does seem like the best option, so I intend to sit down to it and learn it better. It loo
by yakubin 4y ago
I’ve had very limited contact with Perl, but for scripting purposes it does seem like the best option, so I intend to sit down to it and learn it better. It looks like a great next step after sed and awk (perl -pe). I love the ability to write terse scripts, reasonable speed for a scripting language and, as you said, backwards-compatibility (such a stark contrast compared to Python).
- stjohnswarts 4y agoI would argue that ruby as almost all the strengths of perl and conciseness with more coherency if you want a perl-like fluidity and terseness. I personally like python for anything that becomes more than a 100 lines of bash.
- kqr 4y agoDoes Ruby come pre-installed on virtually every Unix-like system out there?
- ARandomerDude 4y agoIf it's not installed already, Ruby will be installed ASAP on any machine I use.
- someRandoJunk 4y agoYou're confusing perl with ruby there.
- jrochkind1 4y agoNo, and if it is, who knows what version it is. I think that's the main thing preventing one from using ruby like this. It is otherwise preferable in pretty much every way. Perl is kind of pre-installed on virtually every Unix-like system for what are at this point historical/legacy reasons. It is unlikely any other language can ever achieve this at this point.
- throwaway111555 4y agoAFAIR, Red Hat stopped including Perl by default since RHEL8 (
- kqr 4y agoIndeed. As much as I would like to use Ruby or Raku for this type of stuff, I keep coming back to Perl because it's simply... there. Sure, I could probably install Ruby on any machine I want it, but it's not just technical availability. Socially, Perl serves as a quite obvious Schelling point. I don't have to convince four other people to learn Ruby, because Perl is what everyone would gravitate to even in isolation, again because it's just... there. (That said in recent years I've had to switch to Python for some things aimed at a younger audience. Oh well.)
- Toutouxc 4y agoJust a data point — Ruby, Perl and Python have all been deprecated [0] in macOS. [0] https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes#3318257 https://developer.apple.com/documentation/macos-release-note...
- deleted 4y ago[deleted]
- btilly 4y agoDue to poor coding practices (eg monkeypatching) and a weaker testing culture (by default Ruby does not run unit tests when installing libraries) I've found Ruby to be substantially less reliable than Perl. However the world has moved on to Python. So I curse every time I again have to look up how subprocess works for what I'd do in Perl with backticks.
- int_19h 4y agohttps://amoffat.github.io/sh/ https://amoffat.github.io/sh/
- btilly 4y agoThe documentation for that says, "Specifically, Windows is not supported." My use case was for scripting git operations. And the list of target environments included Windows. So no, that wouldn't have worked for me.
- thenipper 4y agoCheck out plumbum: https://plumbum.readthedocs.io/en/latest/ https://plumbum.readthedocs.io/en/latest/ It supports mac, Linux and windows.
- fomine3 4y agoTIL (as a light Perl user alternative to awk) CPAN runs test on install. Is there any other language package manager runs tests by default?
- liveoneggs 4y agothat is super dangerous, just like some other dangerous parts of perl where it can run code during the compilation phase
- btilly 4y agoA lot of languages allow the running of arbitrary code on install, so it is not particularly dangerous that Perl allowed it. However you have no idea how many bugs got caught because the test run uncovered platform specific bugs. This is exactly what gave Perl a good name for being portable. Doubly so given that Perl always did this, starting back in the 1980s.
- ilyash 4y agoFor that, there is Next Generation Shell. Also works like a charm even before 100 lines. For example when structured data is needed. Some other advantages over bash are error handling, automatic command line arguments parsing (similar to Raku, btw), standard library with functions like warn(), log(), debug(), retry(), etc that you have likely implemented hundreds of times in your bash scripts. Disclosure: I'm the author.
- senorsmile 4y agoThe "Learning Perl" book from O'Reilly is the best book to do this (and imho is one of the best written programming books).
- jbullock35 4y agoLearning Perl is a classic of the form---the best intro programming book that I've ever seen, at least for smart readers who've done some kind of programming (any kind, with any language) in the past. The contrast to Learning Python is noteworthy. The latter book is useful, too, but it's about ten times bigger and much less focused on introducing a language.
- cutler 4y agoI find Mark Lutz's writing style extremely tedious, having forced myself to wade through "Learning Python".
- weare138 4y agoLearning Perl is a great book but for anyone new make sure you get a copy of the 7th addition. It originally came out in '93. The 6th edition is 12 years old now.
- barrenko 4y agoYup, I'd almost recommend it to a non-programmer.
- HeckFeck 4y agoThe Modern Perl book is great, it explains a lot of the Perl-isms to a modern audience. http://modernperlbooks.com/ http://modernperlbooks.com/ is where you can read it for free.
- asicsp 4y agoI wrote ebooks on CLI one-liners featuring grep/sed/awk/perl/ruby/coreutils/etc. These are free to read online: https://github.com/learnbyexample/scripting_course#ebooks https://github.com/learnbyexample/scripting_course#ebooks Plenty of examples and exercises.