3 ms·
As much as I appreciate Python, I much rather use Perl as a replacement for complex shell scripts. Perl 5 is ubiquitous, it has been stable for the best part of
by qalmakka 5y ago
As much as I appreciate Python, I much rather use Perl as a replacement for complex shell scripts. Perl 5 is ubiquitous, it has been stable for the best part of the last 20 years and it's unbeatable for all those tasks that involve heavy text processing.
Python is good for complex, structured applications, but shell scripts are not that. Shell scripts are glue, and there's arguably no better glue than Perl.
- m463 5y agoI am well versed in the shell, perl and python. I first learned the shell, and pretty much stuck to it conservatively avoiding bash extensions. Later, I learned perl (around version 4) my first impression of perl was annoyance. $foo = 123; seemed silly because there was a dollar sign on the left side of the assignment. and... $foo, @foo, $', $_, s/abc/def/; all the syntax seemed needlessly cryptic and reinforced the "perl is a write-only language" idea in my mind. But then something happened. At some point all of these idioms went away as I became fluent and could think in perl. Because there were many ways to do something in perl, I found that it become VERY easy to get an idea in my head out into working code. So perl was to me my most expressive language. But what I've noticed is that many people haven't overcome the syntax barrier and perl looks like line noise to them. More worrying is the fact that everyone can get their ideas into perl, but because people solve problems so differently their perl can be vastly different from what I am accustomed to. So a few years later I learned python. The indentation requirement was a minor annoyance, but that was quickly overcome by the consistency and visual structure it added. A more major annoyance was that many things were harder to implement in python. Regular expressions is a huge one - they are a major feature of perl and I had learned to use them liberally. Yet I persisted and with help from the many "batteries included" with python, I was easily writing portable maintainable scripts in python. And they were still readable after 6 months. Now I write only small shell scripts, and past a certain size all other scripting is in python. It's quite easy to write meaningful scripts in python. (I've pretty much lost my fluency in perl via python -- I fumble around now looking at or modifying perl scripts) by the way argparse is quite easily my favorite import in python. parser = argparse.ArgumentParser(argument_default=None) parser.add_argument('-d', '--debug', action='store_true', help='debug flag') parser.add_argument('-c', '--config', default="~/.config", help='config file name') arg = parser.parse_args() if arg.debug: print('config file: %s'%arg.config) ...