Hacker News new | past | comments | ask | show | jobs | submit login

If you interviewed for a perl job, you'd probably be disqualified for writing code that is too readable ;)



I know this is meant as a joke, but I just use this to once again note that Perl actually had a very common linter/pretty printer way before it became all the rage (perltidy/perlcritic). I also wish other languages had a book like Perl Best Practices, that goes beyond just syntactical issues.

To be fair, I once came across a sentiment that was pretty close to "readability is bad". Taken from both the (bourne) shell and awk, perl has lots of short variables that determine parsing input and other matters, like "$/". You can then `use English` to have alternative names for that, but those might not be as well known ("$/" would be "$INPUT_RECORD_SEPARATOR", or "$RS" as a tribute to awk). So the line noise might be more common and thus more understandable than the "readable" version.

I don't quite buy that for e.g. "$INPUT_RECORD_SEPARATOR", but there's an argument to be made for "$RS" or "$ARG" being worse than the Asterix swear words.


> I know this is meant as a joke, but I just use this to once again note that Perl actually had a very common linter/pretty printer way before it became all the rage (perltidy/perlcritic).

And all great perl hackers deliver readable code. But we still enjoy a round of perl golf once in a while. And honor demands, that, if you respond in perl golf style to an interview question, you make it count ;)


Perl is readable, just indent it.


What is the readable indented version of this?

   perl -anle '$w{lc s/[[:punct:]]//r}++ foreach @F; END{print map{"$w{$_} $_ \n"} (sort{$w{$a} <=> $w{$b}} keys(%w))}'


I wrote that as a one liner it’s not supposed to be readable. Here’s a readable version of essentially the same program:

https://perlmaven.com/count-words-in-text-using-perl


I know, I still have my black belt in perl somewhere. The one-liner is readable, too.

Throw in some needless array-referencing-and-dereferencing so people can rightfully consider perl a write-only language...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: