Perl::...gCommas(3pm)

πŸ’– NAME πŸ’–

Okay bestie, welcome to the Perl::...gCommas(3pm) page from User Contributed Perl Documentation. The policy itself is Perl::Critic::Policy::CodeLayout::RequireTrailingCommas β€” put a comma at the end of every multi-line list declaration, including the last one. Periodt. πŸ’…

πŸ¦‹ AFFILIATION πŸ¦‹

This Policy is part of the core Perl::Critic distribution. It's giving official, no cap. ✨

🌸 DESCRIPTION 🌸

Conway (yes, that Conway) suggests that all elements in a multi-line list should be separated by commas, including the last element. Why? Because it makes re-ordering the list by cutting and pasting a little easier. Lowkey genius. πŸŽ€

Here's the vibe check β€” this one is not ok:

    my @list = ($foo,
                $bar,
                $baz);  #not ok

And this one? ok, slay:

    my @list = ($foo,
                $bar,
                $baz,); #ok

πŸŽ€ CONFIGURATION πŸŽ€

This Policy is not configurable except for the standard options. That's the whole config story. πŸ™ˆ

πŸ’€ NOTES πŸ’€

In the PPI parlance, a "list" is almost anything with parentheses. I've tried to make this Policy smart by targeting only "lists" that have at least one element and are being assigned to something. However, there may be some edge cases that I haven't covered. If you find one, send me a note. Fr fr. 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

Copyright (c) 2005-2011 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.


That's the whole page, bestie! πŸ’– This is from perl v5.42.0, dated 2024-10-23, and it's the Perl::...gCommas(3pm) page β€” go forth and comma-slay. πŸŒˆπŸ’…

πŸ“¦ where this page comes from