All Comments
TopTalkedBooks posted at August 20, 2017

I work on Melody which is written primarily in Perl. It's a rather large code base, and I've found the process of learning the Melody code base is identical to any Java system I've worked on.

It really comes down to just working with it, googling when you see behavior you've never seen before and experimentation.

This book is a great reference for picking up Perl in a serious way. It's not very dense and it will teach you a lot about proper Perl development.

TopTalkedBooks posted at August 20, 2017

The Encode module has a way that you can try to do this. You decode the raw octets with what you think the encoding is. If the octets don't represent a valid encoding, it blows up and you catch it with an eval. Otherwise, you get back a properly encoded string. For example:

 use Encode;

 my $a_with_ring =
   eval { decode( 'UTF-8', "\x6b\xc5", Encode::FB_CROAK ) }
     or die "Could not decode string: $@";

This has the drawback that the same octet sequence can be valid in multiple encodings

I have more to say about this in the upcoming Effective Perl Programming, 2nd Edition, which has an entire chapter on dealing with Unicode. I think my publisher would get mad if I posted the whole thing though. :)

You might also want to see Juerd's Unicode Advice, as well as some of the Unicode docs that come with Perl.

TopTalkedBooks posted at August 20, 2017

Learning Perl, 5th Edition is current up to 5.10. There's even a chapter for the smart match operator, just like you want, in addition to the other new features that a beginner will want. If you want to start learning Perl, that's the book to use. Once you get through it, move onto whatever else you want to do. I'll have Effective Perl Programming, 2nd Edition out around the start of spring too. That will be current up to 5.10.1 (and maybe a little farther since we use at least one 5.12 feature in some code).

You really don't want a book on Catalyst or Moose. Anything you read will be out of date because those projects have a high velocity and the practices change pretty quickly. You're going to need to learn the basics before you dive into the advanced topics, anyway.

To continue as a programmer, you're going to have to get used to not depending on books. I can't write them as fast as stuff changes, so you have to learn from the documentation too. That's just how life is.

TopTalkedBooks posted at March 18, 2018

As hobbs points out, if you're sure that you'll be on 5.10 or later, you can use the built-in check:

 use 5.010;
 use re qw(is_regexp);
 if (is_regexp($pattern)) {
     say "It's a regex";
 } else {
     say "Not a regex";
 }

However, I don't always have that option. In general, I do this by checking against a prototype value with ref:

 if( ref $scalar eq ref qr// ) { ... }

One of the reasons I started doing it this way was that I could never remember the type name for a regex reference. I can't even remember it now. It's not uppercase like the rest of them, either, because it's really one of the packages implemented in the perl source code (in regcomp.c if you care to see it).

If you have to do that a lot, you can make that prototype value a constant using your favorite constant creator:

 use constant REGEX_TYPE => ref qr//;

I talk about this at length in Effective Perl Programming as "Item 59: Compare values to prototypes".

If you want to try it both ways, you can use a version check on perl:

 if( $] < 5.010 ) { warn "upgrade now!\n"; ... do it my way ... }
 else             { ... use is_regex ... }
TopTalkedBooks posted at April 07, 2018
It's dusty, but I can't throw it away.

Effective Perl Programming.*

A long time ago, when I was a college kid with tons of free time, I'd sit for hours at Borders* or Barnes & Noble and just read computer books. God bless those employees for never kicking a 20-something poor kid out who lived on free coffee refills, yet never bought books.

At the time, Perl was more significant. Something about its syntax made sense, even though nowadays I cringe at it. Though Python is worse, in a different way...

A decade later, and I still sometimes need to spit out the results of a bunch of commands, iterate through them with some regex, format it, etc. Perl became the internet's 'duct-tape' for a reason.

[1] https://www.amazon.com/Effective-Perl-Programming-Idiomatic-...

[2] https://dealbook.nytimes.com/2011/02/16/borders-files-for-ba...

Top Books
We collected top books from hacker news, stack overflow, Reddit, which are recommended by amazing people.