Live data from Hacker News

Learn Perl in about 2 hours 30 minutes

qntm.org

61–70 of 111 posts

Re: Learn Perl in about 2 hours 30 minutes

#61

If 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…

You 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).

That works of course, but Devel::REPL is much more convenient: (1) you don't have to end your statements with backslashes -- you can paste whole blocks as is, (2) you immediately see what your statement evaluates to, for example typing "42" in Perl debugger simply begins another prompt while typing it in a true REPL returns the value that your statement evaluates to (i.e. "42") -- which is not a big deal with simple statements but gets interesting once you start evaluating regular expressions, for example, (3) Devel::REPL remembers what you typed (or at least it works the same way as your system shell), (4) it is really easy to work out complicated things in Devel::REPL -- see for example this case of currying a function:

   $ my $x = sub { my $x = shift; return sub { $x . shift } }
   $CODE1 = sub { # this is what is returned by Devel::REPL
           package Devel::REPL::Plugin::Packages::DefaultScratchpad;
           use warnings;
           use strict 'refs';
           my $x = shift @_;
           return sub {
             $x . shift(@_);
           }
           ;
         };
    
    $ $x->('hello ')->('world');
    hello world

Re: Learn Perl in about 2 hours 30 minutes

#63
post #43

I'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)

"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 t…

>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

Re: Learn Perl in about 2 hours 30 minutes

#64
post #16

Over the past week I've read "Modern Perl", and will finish it later today: 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 be…

I'm really surprised no one has mentioned Higher Order Perl. It's not just an excellent Perl book - it's an excellent programming book. Even if you don't plan on coding in Perl, HOP may change how you write in Python, etc. Also, the pdf download is free: http://hop.perl.plover.com/

Re: Learn Perl in about 2 hours 30 minutes

#65

I'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)

Lots of people know Perl well, but they all know different subsets of it.

Same applies to C++ and Vim.

Re: Learn Perl in about 2 hours 30 minutes

#66
post #46

I 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.

"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.

Is it that bad in Perl 6 too?

Re: Learn Perl in about 2 hours 30 minutes

#67

Oh 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.

Oh 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.

lol so do all the languages mentioned above plus they are prettier.

Re: Learn Perl in about 2 hours 30 minutes

#68

Question: Why don't people transition to Perl 6?

Not 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.

Re: Learn Perl in about 2 hours 30 minutes

#69

I'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)

Lots of people know Perl well, but they all know different subsets of it. Same applies to C++ and Vim.

Alright you win -- I'll rephrase to be accurate: "know Perl but are looking for a job!" Often if they were good they'd be busy -- and yes you can claim that about any programming language too unless it's unpopular...

Re: Learn Perl in about 2 hours 30 minutes

#70
post #16

Over the past week I've read "Modern Perl", and will finish it later today: 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 be…

Were 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.

No 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/

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.

Post reply on HN