Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

While simple, this rule is not known among many developers and is not obvious to those unware unaware of it. Consequently, do not prefix an integer with leading zeros. If it is to be interpreted as octal, use the oct() function, which clearly indicates the number to be treated as octal.

Code Block
langperl
my $perm1 = 0644;      # noncompliant, octal
my $perm2 = "0644";    # noncompliant, decimal
my $perm3 = oct("644");  # compliant, octal
my $perm4 = 644;       # compliant, decimal

...

Tool

Diagnostic

Perl::Critic

ValuesAndExpressions::ProhibitLeadingZeros

B::Lint

Illegal octal digit.*

Bibliography

 

...

Image AddedImage AddedImage Added [Conway 2005], pg. 58. "Leading Zeroes"Image Removed      02. Expressions      [!CERT Perl
Secure Coding Standard^button_arrow_right.png!|EXP31-PL. Do not use the two-argument form of open()]