ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I don't really care if it's getting me a job or not, I'm thinking about
perl as a practical tool to help me get jobs done. What do you guys
think of perl and what is your typical usage of it ? like, when you
have a thing to do, what is your criteria for choosing perl over, say,
bash, awk, grep, sed and similiar tools ?
perl knows all of bash, awk, grep and sed (and even more) together. Actually you can do everything with perl, like database access, web server, package management or the nowadays fashionable microservices (amongst other things), just perl itself is out of fashion. So probably better to learn python or java.
The most important feature of perl is the regex which is extremely powerful and used everywhere. It is definitely worth learning those perl regular expressions.
It is not a quick "pick-up-and-run-with-it" scenario although you can pick up the bits you need fairly quickly. But you need to know what you need to know ...
And of course there is the small matter of which perl.
To be honest as a now apparently unemployable has-been, I find my need for perl diminishing toward zero these days. YMMV.
And of course there is the small matter of which perl.
Exactly. It seems Perl 6 has to be seen as a different (new) programming language,
claimed[1] to be one (or many) generations ahead of the competition (including java,
nodejs, swift).
If you've written, or are intending to write a bash script that needs to make heavy use of sed/awk or where whitespace or escaping characters becomes an issue then perl5 is probably a better choice.
IMO its niche is in writing small/efficient programs that achieve surprisingly much with a surprising small amount of code: hence why perl5 one liners are such a thing.
When using it for small tasks you don't really need to go into that much depth with it, so yes, it's still worth learning the basics, just don't get carried away and try and use it for stuff that it's really not suited for.
It's a useful tool for a sysadm to have in his toolkit, but as others have said, it's very much out of fashion these days.
The most important feature of perl is the regex which is extremely powerful and used everywhere. It is definitely worth learning those perl regular expressions.
I got by without sed or awk for years because perl is a superset of those capabilities. If you are doing heavy pattern matching or processing text, then it is unequaled.
It’s funny, fifteen years ago everyone was saying how Perl was shooting itself in the foot with a massive language redesign, because the world was clearly going to switch to Python and Ruby. Well everyone did switch to Python and Ruby, but now everyone’s got the itch to switch again because it turns out Python and Ruby weren’t designed for concurrent code execution. Maybe shooting yourself in the foot isn’t such a bad strategy, if what you need are bionic robo-feet.
I find perl to be my go-to language for any major project. I’ve used it for elaborate, complex data collection and analysis, compilation, formatting and output of the collected data. Got started with an application that collected data about job opportunities, storing it in a “flat file” (‘cause we didn’t know if a database was available), and displaying it on a website.
Since, I mostly use databases, which is not difficult in perl. I use it for “web-based applications”.
I use sed pretty much only for one-offs, and I’ve never got around to learning awk at all…never mind java or python (tab formatting? Really? Shades of AS400…)
As has been said, grokking perl regex is essential. It is a rabbit hole, but I like it down here.
I find perl to be my go-to language for any major project. I’ve used it for elaborate, complex data collection and analysis, compilation, formatting and output of the collected data. Got started with an application that collected data about job opportunities, storing it in a “flat file” (‘cause we didn’t know if a database was available), and displaying it on a website. Since, I mostly use databases, which is not difficult in perl. I use it for “web-based applications”.
I use sed pretty much only for one-offs, and I’ve never got around to learning awk at all…never mind java or python (tab formatting? Really? Shades of AS400…)
As has been said, grokking perl regex is essential. It is a rabbit hole, but I like it down here.
I'm with you, scasey and Turbocapitalist. It's usually my go-to as well, since it can process files much more quickly than anything else I've used, and DB access is robust as well. Python is handy, too, but perl is more useful (no matter if it's perl or raku. )
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,521
Rep:
I was going to teach myself after retiring, bought the books, then seemed to lose interest; other things took up my time, but if serious, I'll suggest the Perl Mongers forum, they like to encourage newbies, I found, & they have lots of info.
If you seriously want to use Perl (and I find it my most useful tool after bash) then study Perl-5. Perl-6 is not a language, it is a language standard. Implementations come with different names and degrees of implementation of the standard, but Perl-5 is a very real, and powerful, engine. Learning is never wasted!
Perl one-liners is almost a different animal, and commands that can solve problems with a single line of code on the command line can serve you well in many environments. Plus, they are fun!
I've used Perl5 for almost all the things mentioned above by others at different times.
Since you say you're not bothered about it getting you a job, I'd say go for it!
It's a lot of fun and very powerful and flexible.
As above, the gurus live over at perlmonks.org.
Docs at https://perldoc.perl.org/ . One of the great things about the docs is the amount of examples used to illustrate every cmd; the opposite of (most) *nix man pages
See also https://learn.perl.org/tutorials/.
I highly recommend the Learning Perl book (aka Llama book) and the Perl Cookbook .
I liked and enjoyed perl very much (yes, that was in the previous century). It is really powerful and flexible and efficient and .... No doubt.
An additional link: www.cpan.org which contains the available perl modules (you may try to compare it to python/java modules).
And an additional thought: apt, apt-get and the whole package management system was written in pure perl, but now you can find "extensions" written in python. What a mess!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.