Perl::...gZeros(3pm)

πŸ’… NAME πŸ’…

okay so this is the Perl::...gZeros(3pm) manual, filed under User Contributed Perl Documentation, and the full policy name is Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros. Its whole thing? Write oct(755) instead of 0755. Slay. πŸ’–

πŸ¦‹ AFFILIATION πŸ¦‹

This Policy is part of the core Perl::Critic distribution, periodt β€” it's not some random side quest. 🫢

✨ DESCRIPTION ✨

Perl interprets numbers with leading zeros as octal, bestie. That's the vibe check. If that's genuinely what you really want, it's better to use oct and make it obvious. No cap. 😭

$var = 041;     # not ok, actually 33
$var = oct(41); # ok

chmod 0644, $file;                              # ok by default
dbmopen %database, 'foo.db', 0600;              # ok by default
mkdir $directory, 0755;                         # ok by default
sysopen $filehandle, $filename, O_RDWR, 0666;   # ok by default
umask 0002;                                     # ok by default

use POSIX 'mkfifo';
mkfifo $fifo, 0600;                             # ok by default
POSIX::mkfifo $fifo, 0600;                      # ok by default

Those # ok by default comments are literally the policy being like "this one's fine, bestie." πŸ’…

πŸŽ€ CONFIGURATION πŸŽ€

If you want to ban all leading zeros β€” like, all of them β€” set strict to a true value in a .perlcriticrc file. It's giving "no zeros allowed at the function." ✨

[ValuesAndExpressions::ProhibitLeadingZeros]
strict = 1

🌸 AUTHOR 🌸

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> β€” iconic, honestly. πŸ‘‘

Copyright (c) 2005-2023 Imaginative Software Systems. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.


okay bye bestie! This page is from perl v5.42.0, dated 2024-10-23, and it's the Perl::...gZeros(3pm) manual. Drink water, chmod responsibly, and remember: if you meant octal, say oct. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from