4 ms·
I have long thought Perl can do anything Python can, and then some. I still use Perl one-liners to find/change strings in code bases: perl -pi -e 's/somestring
by wainstead 9y ago
I have long thought Perl can do anything Python can, and then some. I still use Perl one-liners to find/change strings in code bases:
perl -pi -e 's/somestring/newstring/g' $(ag -l --python Foo)
Does Python have an equivalent?
I think the fabulous Python libraries for data science have really propelled the language to the top of the list, in terms of users.
- kibwen 9y agoAgreed that Python still isn't as good at Perl at command-line scripting (which isn't a denigration; Python is good at it, but Perl was born for it). Also agreed that Python's current trajectory is buoyed by data science (compare Ruby, whose ascent via the web went hand-in-hand with Python, but which never took off for other domains and faded as new languages entered the web space). But that's a separate phenomenon, and probably has even less to do with comparisons between Python's and Perl's syntax (for years the data science crowd has been demanding more syntax from Python, e.g. a dedicated operator for matrix multiplication).
- emodendroket 9y ago> I have long thought Perl can do anything Python can I mean, yes, they're both Turing-complete languages, so one can be used to do anything the other can. I guess the actual question is whether it makes those things easier to do, and I think the same properties that make Perl great for one-liners make it harder for long-lived, large projects.
- richardwhiuk 9y agoYou could have just used sed for that?
- throwaway7645 9y agoSo Perl was built because Sed/Awk had "whipupitude", but fell short of being a real application language like C which was great and fast to run, but slow to develop in. Perl was the middle ground which took the power of Sed/Awk/Bash and made it faster and more respectable and added a huge module repository. Of course take this with a grain of salt.
- gh02t 9y agoCPython doesn't really have a "stream mode" like `perl -pi`, but you could easily make a pretty trivial wrapper to do it if you found yourself wanting to duplicate that functionality. I'd much rather use sed or awk in your specific case and similar, but to each his own.