Archive for the ‘Perl’ Category

PBP: 041 Here Documents

Thursday, September 18th, 2014

The PBP tells us to use here documents when a multi line string is too long.  It suggests two lines is long enough for a single string, and anything longer should be a here document. (more…)

PBP: 040 Multiline Strings

Monday, September 15th, 2014

The PBP suggests breaking your strings on any embedded newlines so they look in code something like they’ll look when output. (more…)

PBP: 039 Long Numbers

Thursday, September 11th, 2014

Great big numbers full of digits are hard to read and be sure they’re right, so the PBP suggest using the magic underscore in the numbers to spread them out and make them more readable. (more…)

PBP: 038 Leading Zeroes

Monday, September 8th, 2014

Best Practice: Don’t pad decimal numbers with leading zeroes. (more…)

PBP: 036 Escaped Characters

Thursday, September 4th, 2014

The PBP suggests using named escape characters instead of hardcoding ASCII values.  It has some reasonable examples, such as this: (more…)

PBP: 035 Single-Character Strings

Monday, September 1st, 2014

Much like empty strings, the PBP suggests being careful of how you write single character strings.  It points out a number of them it considers “ambiguous”, including: (more…)

PBP: 037 Constants

Saturday, August 30th, 2014

Mr. Conway’s book suggests that constants are good but “use constant;” is the wrong way to go about them.  It suggests the Readonly module.  Later commenters have suggested Const::Fast instead.  Feh, I say. (more…)

PBP: 034 Empty Strings

Thursday, August 28th, 2014

The PBP suggests never using “” or ” for empty strings, and using q{} instead.  Because clearly that’s so much more readable. (more…)

PBP: 033 String Delimiters

Monday, August 25th, 2014

The PBP suggests using interpolating string delimiters only when they’re needed.  How much of my time do I get to waste changing single to double quotes because there’s a contraction in a message, or the other way because there isn’t? (more…)

PBP: 032 Utility Subroutines

Thursday, August 21st, 2014

Here’s where the PBP tells you to prefix “internal use only” subroutines with an underscore.  Why it calls them “utility subroutines” I don’t know. (more…)