No space before the semicolon
我看不出有什么理由.我知道在英文之前,不应该有两个字符之间的空格(如“?”,“;”,“!”),但是我不明白为什么在编写Perl代码时应该是一个规则.
我承认我个人在分号前使用空格.我的理由是使声明更加清晰.我知道这不是一个很强的理由,但至少这是一个原因.
print "Something\n with : some ; chars"; # good print "Something\n with : some ; chars" ; # bad??
第二个坏的原因是什么?
解决方法
Each programmer will,of course,have his or her own preferences in regards to formatting,but there are some general guidelines that will make your programs easier to read,understand,and maintain.
并从描述部分的第三段:
Regarding aesthetics of code lay out,about the only thing Larry cares strongly about is that the closing curly bracket of a multi-line BLOCK should line up with the keyword that started the construct. Beyond that,he has other preferences that aren’t so strong:
Perl程序员的风格只是一个惯例.如果你不喜欢它,你可以选择忽略它.我会比较Sun’s Java Style guidelines或the suggestions for indenting in the K&R C book.有些环境有自己的指导.这些恰恰恰好是Perl的建议.
作为Jon Skeet said in a deleted answer这个问题:
If you’re happy to be inconsistent with what some other people like,then just write in the most readable form for you. If you’re likely to be sharing your code with others – and particularly if they’ll be contributing code too – then it’s worth trying to agree some consistent style.