20 ms·
Learn Perl in about 2 hours 30 minutes
- unshift 15y agonot mentioned in the article is that apparently Moose is a really good OO system for perl, but (in my opinion) about 10 years too late.
- rednaught 15y agoToo late for modern Perl or too late for something else?
- rjbond3rd 15y agoMoose is a great OO system, period. I'm sorry that it's too late for you, but it's not too late for me :)
- chromatic 15y agoHow is it too late? Ten years ago, significant pieces of Moose did not exist anywhere. You can make the argument that if Perl 5 had had a better OO system not borrowed from Python, Moose might not exist now. That may be true in part, but I suspect significant pieces of Moose would still have to exist.
- deleted 15y ago[deleted]
- kyleburton 15y agoI think it's 'too late' in the sense that Perl may have lost some developer share b/c people started looking elsewhere for direction - and Moose hasn't been strong enough a reason for them to come back. (said as someone who used and advocated Perl in production for 12+ years but no longer actively uses it) At one point Perl was the golden child of dynamic website development. It was really attractive to both developers and business types because of the productivity increase over other technologies - you could ship faster (which is what often counts most). It has other viable competitors in that space now. Devs have a limited amount of time to invest in any technology - once they've reached a certain threshold of investment getting them to switch is nigh impossible (see also language flame wars - which are about that threshold more than any real differences between most languages).
- doctoboggan 15y agoWould it be beneficial to know this alongside of Python, or is it more used instead of Python?
- buckwild 15y agoI personally found that I didn't need Perl at all. I am a bioinformatics programmer/scientist and Perl was the first language I learned. I find that whatever I can do in Perl I can do with bash/awk/sed--and whatever I can't do with bash/awk/sed I can do in Python. I've never been happier.
- lambda_cube 15y agoWhatever you can do in one Turing complete language you can also do in all other Turing complete languages. The point isn't what you can do, the point is what tasks are easier, simpler or faster to do in one language compared to another language, while also respecting how hard the language is to learn to get to the point where can can do what you want (easily). I would prefer to use Perl over bash/awk/sed since Perl is good at the same things and more and has alot more libraries.
- neuroelectronic 15y agoobviously in such a small (in terms of computing in general) discipline, a general purpose language might not be the best. Now if you want to publish your results to AWS and a website and pull data from a website front-end, etc. You can probably do it quickest with ducttape.
- jrockway 15y agoPerl's advantage over bash/awk/sed is that you can test, organize, and maintain code more effectively. This may not matter if you are programming to solve tiny unrelated problems, but it's a waste of effort if you are doing similar things frequently. Python is basically Perl but with different syntax, libraries, and community.
- Cushman 15y ago
- pitchups 15y agoWish there were similar ones for all the other languages - PHP / Python etc. I always thought that most programmers and web developers experienced in one language can quickly pick up the major features of another lanaguage, if there was a quick overview of this sort. Know of any sites that do this? Maybe this is a great opportunity for someone to put together a site like that?
- benologist 15y agoNot just an overview but something where you pick the languages you know and it shows you side by side examples doing the same thing. I know there's a site that does that (can't remember the name) but having it side by side with a great overview like this would be awesome.
- chromatic 15y agoPerhaps you're thinking of PLEAC? http://pleac.sourceforge.net/ http://pleac.sourceforge.net/ Or perhaps Rosetta Code? http://rosettacode.org/wiki/Main_Page http://rosettacode.org/wiki/Main_Page
- benologist 15y agoRosetta Code's the one I was thinking of, but I really dislike their structure - I never want to see how to do something in dozens of languages, almost all of which aren't relevant to me. What I would love to see is: 1) select language you want to learn 2) select languages you already know 3) you get a cheatsheet like the OP that goes through all the basics (and maybe even more detailed), and all the code samples are changeable ala MSDN where you click "C#" or "VB.NET" or whatever to see the code in that language: http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx#Y4876 http://msdn.microsoft.com/en-us/library/system.drawing.bitma...
- pitchups 15y agoPerhaps someone can use Rosetta code as a starting point (their content is GNU licensed) and build a site that does what you are suggesting - where it only shows you the features for the languages you want to learn, based on the ones you know.
- wallfly 15y agoOver the past week I've read "Modern Perl", and will finish it later today: http://onyxneon.com/books/modern_perl/ http://onyxneon.com/books/modern_perl/ The ebook/PDF edition is free! It's a great book for learning (modern) Perl basics if you're already familiar with programming concepts and another language like JavaScript (which is where I'm coming from). Actually, I think the knowledge and best-practices gleaned from the book will help to make me a better programmer in a general sense (not just in terms of the Perl language). It's well written, a pleasure to read and I highly recommend it.
- tedkalaw 15y agoWere you previously a Perl programmer at all? And are you learning it for any particular purpose? I've always wanted to give Perl a go but can't find something I want to use it for.
- elb0w 15y agoShouldnt be too hard, perl does just about anything.
- Goladus 15y agoPersonally, I've found knowing perl useful in some of the same ways that I've found C useful. Perl is still one of the most popular systems scripting languages and perl code always seems to show up somewhere important. If I were into serious application development I would probably try a project with Clojure before perl, but there are a lot of situations where that might not be desireable (eg you don't want to use the JVM).
- jonathansizz 15y agoText processing (data munging, web programming, networking, system adminstration), of course!
- wallfly 15y agoNo previous Perl programming-experience. I've been consciously aware of Perl since at least 1998 and even poked at the source code of some scripts here and there, but didn't bother to really learn anything about it until recently. A brief explanation; perhaps someone here will be inspired or is thinking along similar lines: I've been using an "object system" for JavaScript named Joose: http://joose.it/ http://joose.it/ Joose is amazing and is, roughly speaking, a port of the Moose object system for Perl to JavaScript. (Moose is mentioned in various comments below and many times in the "Modern Perl" book.) The principal author/maintainer of Joose v3 (Nickolay Platonov) has developed an ecosystem of tools on top of Joose3 and for Joose-oriented distributions (github.com/SamuraiJack). Much of their design is inspired by popular distributions in Perl's CPAN (Nickolay has a strong background in Perl, obviously). And some of them are still tied into Perl libraries, not simply ports to JavaScript. As node.js and its package manager NPM have evolved rapidly in the last 12 months, some of the Joose stuff is lagging behind and in need of an overhaul, e.g. Nickolay's "JSAN plugin" for Dist::Zilla. I've been wanting to help, but it's difficult to hack on Perl code if you don't even know the syntax. Well, that's where chromatic's book has come to the rescue! To be honest, it's been a real eye-opener and, as I suggested earlier, I think this Perl learning-experience is actually going to be a big boon for me in the near term and into the future. It's already allowing me to view Joose and related libraries through new eyes.
- creativityhurts 15y agoBut why?
- mellery451 15y agoI do wish he had mentioned the smart match operator ~~ as it nearly eliminates the confusion between EQ and ==. Of course, if you're dealing with legacy code, then you still need to understand both (or all three), but new coders might be well advised to start with smart match.
- grout 15y agoSmart match is undergoing revision because, frankly, it's too smart. I don't mind that he left it out, and I'm one of the core devs.
- mjd 15y ago"Smart" match is a pile of shit, and anyone reading the manual description for it should conclude the same. You can't know what it does unless you can remember the details of a 23-item table. It's undergoing major revision, and not a minute too soon.
- koenigdavidmj 15y agoIs it that bad in Perl 6 too?
- chromatic 15y agoNo, because Perl 6 has a coherent type system.
- TheRevoltingX 15y agoPerl rocks, I can testify to this: http://4.bp.blogspot.com/_Vtq6sCdzyKs/TK8Fooqqt9I/AAAAAAAAAGY/AdcMq7zxYUA/s1600/solomon_single_server.png http://4.bp.blogspot.com/_Vtq6sCdzyKs/TK8Fooqqt9I/AAAAAAAAAG... I built a 2D mmorpg using Perl and Erlang. The languages a lot of people whine about when it comes to syntax. Syntax is the LAST thing I had to worry. I'm really happy that I chose those two languages.
- ChuckMcM 15y agoNice concise writeup. The only important thing he missed as far as I can see is that the '..' operation can create anonymous arrays of sequences of characters too so 'a' .. 'z' gives you an array of all the letters between 'a' and 'z'.
- jlarocco 15y agoNot as useful as 'a'..'z', but the '..' operator works on strings, also. For example, 'aa'..'zz'.
- michaelpinto 15y agoI've been working with Perl programmers for just about ten years now and the one thing I've sadly learned is that while many folks claim to know Perl, but only a small group can do it well. (although granted you can apply this reality to any other programming language)
- Swannie 15y ago"Write once, read never" comes to mind. So many single/double char operators which need to be memorised with Perl, before you can start comprehending the programs. Not to mention Perl hackers used to pride themselves on super succinct code - in certain circles it use to be popular to include one liners to do complex stuff in email signatures. (Not complaining though, Perl was the first language I used, and probably the simplest for text file processing in CGI's back in the day.)
- chromatic 15y agoSo many single/double char operators which need to be memorised with Perl, before you can start comprehending the programs. Nonsense. All you have to know is how to identify operators and how to use the documentation. The Modern Perl book covers that in a page or two.
- SkyMarshal 15y ago>Not to mention Perl hackers used to pride themselves on super succinct code - in certain circles it use to be popular to include one liners to do complex stuff in email signatures. One of my favorite examples of that was back when DVD John released DeCSS, and some Perl hackers turned it into a 7-line Perl script: http://www.wired.com/culture/lifestyle/news/2001/03/42259 http://www.wired.com/culture/lifestyle/news/2001/03/42259
- kamaal 15y agoHow do you do that in other languages? Whatever language that you will ever use will require you to understand and to a degree memorize your usual keywords, operators and syntax elements and rules concerning interplay between them. Regarding other stuff, building good software requires understanding a lot of things which have nothing to do with Perl. Understanding concepts like recursion, closure, OO, functional programming concepts etc etc. These have to be first understood in theory. The Perl syntax is only a notation in which you express your ideas. Besides that designing good software requires people to understand design patterns, designing maintainable software requires people to work on large project under sound practices. Writing fast and efficient software requires people to learn Algorithms and data structures. And so on... These principles remain the same regardless of the programming language you use. Then why is it that only in case of Perl people hold the language responsible for everything. To be frank, I have seen crappy code more often in other languages than in Perl. I have seen over abuse of certain element like XML in Java, and now these days Python. The fact is if your technology community is huge you get a lot of crappy people along with your usual set of good people. This happens for various reasons, Everybody wants to learn something that is famous as it helps for Job reasons. Perl's strength apart from your usual language kit is CPAN, language tools to produce highly useful rapid scripts in time. Heavy data lifting, data munging. A gentle glance at things like Moose, Modern Perl, Devel::Declare and all associated software with them(Catalyst, DBIx::Class), will show you the genius of Perl community in coming up such great stuff in time.
- d2 15y agoSam, you've certainly made an enemy out of every member of the Perl community with this sarcastic and incomplete post. Once you've gotten through OReilly's beginner Perl books and "Programming Perl", if you truly want to learn how to scale Perl in the enterprise, read Damian Conway's Object Oriented Perl. Once you can write solid consistent OO Perl, read "Apache modules with Perl and C".
- benatkin 15y ago> Sam, you've certainly made an enemy out of every member of the Perl community with this sarcastic and incomplete post. What does the Perl community mean to you? It must not include Sam. Is it people who organize and participate in conferences and get indignant at the slightest negative comment?
- sigzero 15y agoNo, we are not all like that. Fortunately. The author states: "A bunch of new people started at work and we use a lot of Perl in our department. So I put together some information about Perl and I thought it might be worth sharing so here it is." For that purpose, it is fine.
- deleted 15y ago[deleted]
- raffi 15y agoHrm, someone spends a lot of time putting together this documentation about Perl and you claim he's making enemies now. The correct answer when someone tries to contribute is "Thank you". If you don't agree with the contribution, consider "Thank you, but..." I don't think the documentation is that bad. I don't read it as sarcastic either. Sure it raises some of Perl's warts, big deal.
- mjd 15y agoI'm a fairly well-known member of the Perl community, and I thought it looked okay. I'm not angry and I'm not Sam Hughes' enemy.
- 15y ago
- bluekeybox 15y agoIf you really want to learn Perl, you must install the read-eval-print loop (REPL) utility. If you have never used this utility, I will have serious grounds to doubt your Perl skills. Unlike Ruby or Python (or most other modern high-level programming languages), Perl does not come with an interactive REPL shell, which makes no sense at all, since, due to Perl's obscure syntax, someone trying out Perl would benefit at least twice as much from a REPL shell than someone learning Ruby or Python. Fortunately, the Devel::REPL package remedies this. Installing it is super-simple: $ sudo /usr/bin/perl -MCPAN -e shell > install Devel::REPL Once installed, simply open your terminal and run: $ re.pl Once you have the REPL shell running, you can pretty much copy-and-paste into it examples from this tutorial (or any other) and watch what Perl has to say in response.
- hippich 15y agosimply: $ sudo cpan Devel::REPL also you can do this: $ perl -e 'print "Hello World!\n";'
- berntb 15y agoHuh, I thought "everyone" used perlbrew now? It has been on my todo to try the REPL for a long time, but since Perl is the most powerful command line tool in bash, I've never seen a reason to use an interactive tool. alias p=perl p -e '...' p -ne '....' # etc. Edit: With powerful I didn't mean "rm -rf", etc. :-)
- walrusty 15y agoI don't use perlbrew. Haven't tried it, since installing your own Perl by-hand is easy enough.
- krishna2 15y agoYou can also go into the debug shell (which is REPL) by giving it some valid statement: Here is an example: shell> perl -de 1 This will take you into the perl debug shell (after evaluating the string "1" which is true).
- berserkpi 15y agoSure, just in case you really want to learn Perl...
- ez77 15y agoAs an aside, the author's clarification [1] of the many terms related to the UK, Britain, etc. are very enlightening. [1] http://qntm.org/uk http://qntm.org/uk
- chaostheory 15y agoQuestion: Why don't people transition to Perl 6?
- chromatic 15y agoFor me, it doesn't have all the libraries I use in Perl 5 whether as libraries or core features.
- baudehlo 15y agoBecause it's 1000 times slower and doesn't have a wealth of libraries available to it, and it isn't finished, and it's not 100% stable.
- squidsoup 15y agoI suspect they're frightened of the butterfly.
- bluekeybox 15y agoNot enough people on the bandwagon, competition from Ruby/Python/JVM languages on the high end and Perl 5 on the low end, and last but not least the fact you can't use libraries written for Perl 5 with Perl 6. I wrote a medium-sized project in Perl 5 two years ago. It is my day job right now to work on it. I have very little interest in rewriting it from scratch in any language, but if I did, it would probably be either Ruby or something on the JVM.
- chaostheory 15y agoGood point about Ruby. I forgot that it's the good looking and smart bastard child of Perl.
- derrickpetzold 15y agoOh my why would anyone want to lean Perl anymore? Unless you are working with a legacy codebase learn Python, Ruby, Java, C#, Erlang, Scala, Haskell... in other words run the f away from Perl if you can unless you are into S&M.
- chromatic 15y agoOh my why would anyone want to lean Perl anymore? Because it's powerful, it's easy to start, it's flexible, it's productive, it's ubiquitous, and it has an unparalleled extension ecosystem devoted to quality and ease of use.
- derrickpetzold 15y agolol so do all the languages mentioned above plus they are prettier.
- rjbond3rd 15y agoI don't think you read what you're responding to. How can they all have an "unparalleled extension ecosystem"?
- derrickpetzold 15y agoThank you I did read the post. Python has pypi. Ruby has gems. I'm not going to google the rest but if they don't have one there is no reason why they can't. And FYI pypi is better than CPAN so all the other stuff in the that post is crap imho. I was a Perl dev for ~10 years. Now have about 5 worth of Python. So thank you.
- chromatic 15y agoI'm not going to google the rest but if they don't have one there is no reason why they can't. That somehow fails to convince me that other language ecosystems parallel the CPAN in breadth, scope, maturity, and ecosystem. See CPAN Testers, for example.
- qusiba 15y agoStudied Perl before Python years ago. Never got a chance to actually use it, whereas Python became one of my favorite languages.
- bbbbbbbbb 15y agoPerl is a really great language that i came to love over the years. First, I've been writing PHP stuff then moved to Perl and experienced Java,Actionscript,Javascript,Objective-C,Python... But all of them, Perl was the most powerful and expressive language. For those who learn Javascript, Perl object literal notation should be really easy to get and if you do some jQuery stuff, many things should come naturally to you somehow. Perl supports packages, closure, utf8 since many years whereas they are just coming to PHP (It's a real pain to go back to PHP for some projects... as it looks like a huge trash of functions in the global namespace with no cohesion at all... working with array_, mb_ or preg_* functions is such a pain... hopefully the doc helps in understanding the quirks of the language). The integration of regex as an operator is so nice. q[] or qq[] helps quite a lot and I quickly miss them... Controlling each instance of the program flow in code is very powerful too. I guess the very minimalistic OOP system shipped with Perl did not help get Perl across the board of a wider range of company... Obviously, this le/gend/ary image of unreadable code that one-liners, and to some extend sysadmin community, gave to the language has left a very bad taste in the mouth... and it is now very hard to get rid of. when you look at http://mojolicio.us/ http://mojolicio.us/ or http://perldancer.org/ http://perldancer.org/ for web development, Perl::Critic that analyzes your code for bad coding habits(JSLink like), perltidy that reformat your code to follow your conventions or Devel::NYTProf to profile every line of your code... I don't even talk about CPAN that has always get the job done for me in like 90% of the case... I still have to find a language that offers such a powerful ecosystem. And for those who wonder, Perl is very active here in Japan.
- altxwally 15y ago> Perl is very active here in Japan. Considering the amount of legacy Perl scripts that I have had to rewrite since I got to Japan due to a lack of Perl developers that can mantain them, I'd think that Japan's Galapagos argument does not work so much in this case. I think that it is also losing strength around here.
- bbbbbbbbb 15y agoIt does not mean that Perl is not active in Japan though. Many big companies in Japan uses Perl as the language of choice for their websites but indeed,I won't say that it's not loosing some market share though.
- lelele 15y agoIt is not what Perl you know that will hurt you, but what you don't know.
- kaichanvong 15y agoOH: "I dont believe it is possible."
- known 15y agohttp://perldesignpatterns.com/?PerlDesignPatterns http://perldesignpatterns.com/?PerlDesignPatterns
- vrode 15y agoI hope that the first thing you learn is how to pry open a casket.