I agree that's confusing; regex syntax is very terse, and there's nothing in there to help you learn it. (In regular code, variable and function names can help you infer from context what the other constructs do.) Secondly, it's hard to reason about code that does things that aren't written. "while(<>)" assigning to "$_" for "/.../" to use is confusing. $2 and $3 coming out of nowhere are confusing.
The problem, though, is not with Perl; it's with the author's lack of knowledge of how it works. Regexes are nice once you learn them. Operating on $_ is nice once you expect that to happen. $1 and friends are quite handy.
Finally, most Perl apps don't look like this. Sure, there may be something like this hidden over in an obscure subroutine, but most Perl looks like every other language.
Here's a randomly sampling of Perl from my git repository:
http://git.jrock.us/?p=Template-Refine.git;a=blob;f=lib/Temp...
Basically, it looks like it would when written in any other language. It's not unreadable or crazy, it's just a program.
Finally, here's a more readable version of his example:
while ( my $line = <> ){ # or "readline" if you hate <>
while( $line =~ /<!--(?<comment_body>[^-]+)/g ){
say $+{comment_body};
}
}
One more thing; from the article:Even so, I supect that most readers that know both languages, even Perl fans, will agree with me.
Not true. I don't know Python, so of course I'm not going to be able to use it to write maintainable code. I do know Perl, though, and I bet I can write much better code than the author of this article.
I should note that his program doesn't actually work. It won't work across lines, and doesn't allow "-" in the comment. A full-file parser would do a correct job, and one is available from the CPAN, so it would involve less code anyway.