Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Is it worth knowing Perl? Real-life examples please

by Anonymous Monk
on Oct 23, 2019 at 12:52 UTC ( #11107891=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I just wanted to post this here, to hear opinions from experts.
Is it actually worth expanding my Perl skills, or should I just move to Python? I would consider myself more or less intermediate user, but I know there are more things I could learn. It is just somehow, wherever I turn to, everyone is "talking" Python (or R). And my problem is that I don't really have some good arguments to "defend" my choice.
It would be great if I could hear your opinion on where Perl is really good, where it is actually used nowadays (real-life examples I mean), and, if this is the case, where it excels compared to languages like Python or R.
Many thanks for any input!
  • Comment on Is it worth knowing Perl? Real-life examples please

Replies are listed 'Best First'.
Re: Is it worth knowing Perl? Real-life examples please
by rjt (Curate) on Oct 23, 2019 at 13:34 UTC

    The answer is always "it depends" on where your interests lie, and what opportunities are open to you (or which opportunities you have the determination to create for yourself). If the projects you want to do require Python or R, you should probably learn one of those. I've been fortunate enough to be able to choose the best language for the job for most of my career, and by sheer coincidence I guess, that just so happens to be Perl most of the time. Meaning, the "best tool for the job" definitely has to take into account the skillset of the team (or individual) that will be doing the work, and existing libraries, in addition to the actual project requirements.

    As for community, I'm obviously biased, but I think we have one of the best around.

    Where Perl shines? Perl is general purpose enough for that to be a rather large list. Off the top of my head, bioinformatics is going strong, and things like system programming, text processing, and web development have remained pillars of Perl. jobs.perl.org is a glimpse into a subset of the market for Perl programmers, too.

    Finally, I believe Perl has great value as a teaching language. Even if you never write any "real" Perl, the knowledge you will gain from learning how to write competent Perl code, will make you a better overall developer.

    That's just one monk's opinion.

Re: Is it worth knowing Perl? Real-life examples please
by GrandFather (Sage) on Oct 23, 2019 at 21:23 UTC

    I have written large systems in the past using Perl, most of which could as well have been written in Python but would probably have required twice the number of lines of code. Where I use Perl now is for quick mutable tools and that is where Perl really shines.

    Right at the moment I'm using a Perl script to validate digital filtering algorithms and configurations. I can paste a set of FIR filter coefficients into the __DATA__ section of a script and plot results with Tk using just a few lines of code. Tomorrow I may be using it to parse a log from a USB analyser or data from a logic analyser. In each case it will be a modest number lines of code written quickly and discarded just as fast. For that sort of task Perl feels much more productive than any other language I've used due largely to things like map, grep and Perl's simple but powerful data types.

    If community is important then Perl leads the pack by a vast distance largely due to PerlMonks. I haven't seen anything like PerlMonks that is anywhere near as good for any other language, at least until StackOverflow came along.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re: Is it worth knowing Perl? Real-life examples please
by bliako (Vicar) on Oct 23, 2019 at 23:22 UTC

    I am always happy to see Perl being used in *some* unix administration tools where shell scripting logic is inefficient or insufficient. My Unix purism starts when I see Python or Java(!) being used for such tools. And what's the deal with the different versions of Python? DNF - Fedora's package manager - is written in Python. It's ok but right now I am getting random seq faults after an upgrade - I do not know where to start debugging it. Totally in a loss. It is said they try to convert DNF to C and for a good reason.

    I have used Perl for website scraping a lot: 1) it has quite a few user agents to choose from, even curl, for fetching the webpages, 2) it has adequate HTML parsing modules, 3) it is super easy to use a regular expression to filter your results. Sure one can do the same in Python (or Java) but using regexes there, it is so tedious, for me. Give me the ol' m//g m// (edit:ouch!) form any day.

    In Perl one can inline C, which means you can run custom number-crunching routines or using external C libraries easily. So whatever deficiencies Perl has with number crunching (speed), inline C can compensate - if one is serious. There is also PDL which offers a lot of scientific computing support. And then there is Python with lots of libraries which is convenient, but I get no joy.

    Perl offers Mechanize and WWW::Mechanize::Chrome for interacting with a web site via a web browser. That's really cool and can automate many menial testing tasks. (Mechanize has been translated to Python too). Add to that Perl's very good test framework and you can use Perl for lots of testing.

    And then you have website backends. Once it was mostly Perl. Now there is a lot of php (last days of Rome anyone?) and possibly some Python. But there is joy in using Perl as a backend which also supports templates. (A totally subjective and personal view from my one-time experience).

    You say Python or R. But they have very little overlap. Sure you can multiply two matrices in Python as you can in R. But I will not say it is "one or the other" but "one and some of the other" or just the "other".

    Each programming language has its own culture. If you want to be happy programming in that language make sure you are happy with the culture. The critical question for you would be "Are you comfortable with many ways to do one thing? Or would you rather prefer there was just one way?". Answer that and you will answer your question.

    P.S. Look mumy I haven't slanted Python today!

    bw, bliako

      "Or would you rather prefer there was just one way?"

      Actually two ways: Python and Python3. Having spent most of last night trying to get someone else's Python script running to analyse a few astronomical images and utterly failing partly due to Python/Python3 issues I feel no great warmth for Python/Python3 and Pip/Pip3 at present!

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re: Is it worth knowing Perl? Real-life examples please
by RMGir (Prior) on Oct 23, 2019 at 13:16 UTC
    I guess it depends on what you do...

    These days, most of my scripting is in python, but back in the day, when I had to do a lot of searches through massive log files and do very quick analyses, perl + File::SortedSeek was hard to beat.

    I find python is more readable long-term, but it's VERY hard to beat perl for quick 1-liners (although some of my 1-liners tend to be absurdly long lines...).


    Mike
      I am a data manager and database administrator. I was mainly asking with regards to should one invest nowadays in Python since it is on demand? Or become e.g. Perl expert and not care about it too much? It just seems to me that wherever I read, they ask for Python...

        I’m going to go out on a limb and say: Perl is much better than Python for ad hoc data munging and management and it is the best high level language for terse one-offs written the way *you* think. As far as Big Data® goes, Python has better tools.

        If you are an expert in either, the other will be fairly transparent anyway. A Perl expert will have no trouble using Python tools and understanding well written Python code and mostly vice versa. Perl can be harder, sometimes much harder, to follow because it can be written in so many different styles. At our shop we had a Perl hacker who wrote really clean Perl code but in Java idioms and it is truly a pain to follow that kind of over-engineered 15 packages for a single object and its functions kind of logic.

        You’re the only one who will really know the answer. Like the others already said, it depends.

Re: Is it worth knowing Perl? Real-life examples please
by LanX (Archbishop) on Oct 23, 2019 at 13:34 UTC
        actually I wanted to mention that you "keep a long list of similar nodes" ... :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: Is it worth knowing Perl? Real-life examples please
by cavac (Curate) on Oct 24, 2019 at 09:29 UTC

    I have no idea is Perl has any future value for you, but it certainly has for me. A couple of months ago i started a new big project based on my PageCamel framework written in Perl. This is about my 15th year where Perl programming is my main job, including creating entirely new projects.

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'
Re: Is it worth knowing Perl? Real-life examples please
by talexb (Canon) on Oct 24, 2019 at 19:41 UTC

    As usual, it depends on your situation. I picked Perl up about twenty years ago to replace awk, and luckily ended up finding some work with Perl almost immediately. I've been employed since then, almost exclusively working in Perl. So, for me, it was a really good decision.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: Is it worth knowing Perl? Real-life examples please
by Anonymous Monk on Nov 02, 2019 at 20:17 UTC
    everyone is "talking" Python (or R). And my problem is that I don't really have some good arguments

    Comparing Perl to Python and Rust is like saying "I'm moving on from Linux, to Python!" It doesn't make sense, because Perl is different:

    "Perl is, in intent, a cleaned up and
    summarized version of that wonderful 
    semi-natural language known as "Unix"."
    --Larry Wall. Apr 6, 1994
    
    No one is crusading to replace cat with a dog that does the same thing, because we already have cat, and Unix has been summarized by Perl!
    "It seems like there’s an opportunity for a 
    lightweight statically-linked scripting language. 
    Something between Go and Python." 
    --https://news.ycombinator.com/item?id=20111696
    
    where Perl is really good

    Perl is really good at almost everything it can do which is almost anything thanks to its flexibility, the devoted devs, and the generous people of CPAN.

    where it is actually used nowadays

    Perl is everywhere doing pretty much everything just like any standard unix tool so, astronomers (for real-life example), can cook up a clock after supper to watch Julian time fly:

    perl -MAstro::Montenbruck::Time=jdnow,jd2mjd,jd_cent -e '$|++;print sp +rintf("%-22s","Julian day").sprintf("%-22s","Modified Julian day").sp +rintf("%-22s","Julian centuries since J2000.0")."\n";while(){$j=jdnow +();print"\r".sprintf("%-22s",$j).sprintf("%-22s",jd2mjd($j)).sprintf( +"%-22s",jd_cent($j));sleep 1}'
    where it excels compared to languages

  • Perl can't be beat on the command line for speed of writing and sheer power of one-liners.

  • Then pasting one-liners into files for further development into complete programs.
    #!/usr/bin/perl =head1 DESCRIPTION Watch Julian time fly... =cut use strict; use warnings; use Astro::Montenbruck::Time qw[jdnow jd2mjd jd_cent]; $|++; print sprintf("%-22s","Julian day"). sprintf("%-22s","Modified Julian day"). sprintf("%-22s","Julian centuries since J2000.0")."\n"; while () { my $j = jdnow(); print "\r". sprintf("%-22s",$j). sprintf("%-22s",jd2mjd($j)). sprintf("%-22s",jd_cent($j)); sleep 1 }
  • Then abstracting the mojo out of the programs into modules to reuse the code.

  • Then back to one-liners, using your new modules, to repeat the cycle of virtues.

    The more tools in your programmer's box the better, so learn some trendy languages to talk to the kids. Meanwhile cat, sed, awk, cut, tr, grep, diff, patch, head, tail, sort, bash, perl and more written in C continue to make the world go round. "Let's talk about the language your favorite language is written in!" ;-)

Re: Is it worth knowing Perl? Real-life examples please
by Anonymous Monk on Nov 03, 2019 at 19:30 UTC
    I chose to learn Perl, because I already knew JavaScript and HTML/CSS. And I wanted to learn a server-side scripting language that is well known, well established and plenty of free documentation exists online. I also learned that all Linux computers have perl, which means if I learn this language, I will be able to write programs for Linux. That was my other goal. I want to transition from using Windows to Linux, and I saw that learning perl is the best option. It's like killing two birds with one stone. I'll not only learn a server-side scripting language, but I will also learn how to program Linux. Perfect combination. It's a well-established language, very well known and if the language has any bugs, they are already figured out by now.

    Choosing between Perl and Python would be very easy for me. I don't like the way Python programs look like with all those indentations and missing opening/closing brackets. That is just creepy. Most servers do not offer Python scripting, but they most all support Perl, because as I said, perl is well established and well known.

    For me, the big decision was going with PHP or Perl. PHP is faster and very well-known and very popular. PHP has a lot of advantages over other languages. The #1 thing I do not like about PHP is that PHP code has to reside within HTML files, which are usually already packed with JavaScript/CSS and other stuff. So, if we add PHP into the mix, the files are going to look like total chaos. I also had a hard time testing PHP programs, because I had to upload my php scripts to the web server before I could see them run. It was very inefficient and just a pain. I could not see myself enjoying PHP programming.

    Computer programming and webdesign are my hobbies, so this isn't my main job or career. If you want to be a computer programmer or webdesigner, you should learn ALL languages -- Perl, PHP, Go, Ruby, C#, C++, assembly, HTML/CSS, Java, JavaScript, BASIC, R, and everything. You won't be able to compete in today's market if you only know a fraction of what everybody else knows!

      If you want to be a computer programmer or webdesigner, you should learn ALL languages -- Perl, PHP, Go, Ruby, C#, C++, assembly, HTML/CSS, Java, JavaScript, BASIC, R, and everything…

      The more tools you master, the better for you, of course, but BASIC? Everything? Or you won’t be able to compete…? The things everybody else knows?!¡¡¿⁄¿¡÷11!

      I want to transition from using Windows to Linux, and I saw that learning perl is the best option. It's like killing two birds with one stone. I'll not only learn a server-side scripting language, but I will also learn how to program Linux. Perfect combination.

      This. Perl is fantastic (as everyone knows). It's doubly fantastic on a decent O/S. Perfect combination indeed.

      PHP is faster

      That's intriguing. Maybe you mean "faster to learn", perhaps because there's less of it? Dunno. Do tell.

Re: Is it worth knowing Perl? Real-life examples please
by Anonymous Monk on Oct 25, 2019 at 12:33 UTC
    It is always a good idea to pick up proficiency in yet another programming language, because these are the tools of your trade.   You simply never know what already-entrenched language you will be asked to work with next ... or, how many.   I am currently working with a client who is simultaneously using Perl, PHP, and Python, with a fair amount of RPG, and that is not particularly unusual.   Time that you spend self-learning will usually pay off someday when you least expect it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11107891]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2019-12-12 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?