Lists need to be formatted to be readable. The suggestion is to always use parenthesis, indent after a parenthesis, and line things in columns, all with trailing commas.
The book provides clear examples, which I won’t duplicate here. (more…)
Lists need to be formatted to be readable. The suggestion is to always use parenthesis, indent after a parenthesis, and line things in columns, all with trailing commas.
The book provides clear examples, which I won’t duplicate here. (more…)
The book talks about how confusing the ternary operator can be and how much of a mess it can make. I’m almost surprised it doesn’t say, “Don’t use it.”
It suggests columns instead, with the condition, then the positive result.
The PBP suggests breaking assignments much like it suggests breaking other operators; the assignment leads the broken line:
my $thingy = $stuff + $hard_things + $foo;
This Practice is to break long expressions at lower-possible operators. It actually says “the lowest possible precedence”. At a glance, this sounds like a fine idea, and it, in general, is. The reason given is pretty solid, that you can easily confuse people about precedence by splitting things apart. This will be even more important on operators people may not be familiar with the precedence of. (Quiz: Which is higher precedence “&&” or “and”? Which is higher precedence, “~” or “^”?)
I’ve been watching the YAPC::NA presentations, and saw a mention of this Kickstarter:
https://www.kickstarter.com/projects/2083389021/create-perl-competition-to-the-php-content-managem
This is a project to help get a system written in Perl to compete with WordPress. There is an existing system that’s close, all it needs is time, energy, and developers. It sounds like there’s a great core there, but it’s lost the commercial support it had before, and the one developer can’t go it alone.
The Kickstarter is to try and fund some key work on it, and make it more accessible and as easy to get started as WordPress.
Sadly, the Kickstarter’s getting close to no traction, and that makes it look kind of bleak.
Here’s a signal boost; have a look at the system, read the page (the video has lots of good stuff, but it’s a little wordy) and consider supporting this useful development.
If you can’t support the Kickstarter, maybe you have time to help them get the major new release unblocked and keep it from sinking into the murk of obscurity.
At the end of the video, they point out that a hundred people giving a hundred dollars each will fund it, and get it over some of these hurdles. A thousand people giving ten dollars each would work just as well.
This Best Practice is one that I’ve seen people argue horribly about, and I don’t get it. The suggestion is to avoid doing a big calculation, with sequences of complex operations, in the middle of a statement. Take that complexity, stick it in a variable, and use the variable. (more…)
This Practice is about how to break long lines of code. It suggests breaking them before an operator, so the operator serves as a visual cue on the left, where you’re likely to be reading, that this line is continued from last time.
The Perl Best Practices suggest to align things vertically. They like to apace things out into neat rows of equals, fat commas, braces, and parenthesis. Columns of data, when it will fit, are also approved of. (more…)
The PBP suggests that you don’t “cuddle” an else. This means that the else and it’s opening parenthesis starts on its own line: (more…)
The suggestion in this one was very simple, “Code in paragraphs.” Deceptively simple, because it means different things to different people. (more…)