Perl::...kNames(3pm)

hey bestie πŸ’– this is Perl::...kNames(3pm) from the User Contributed Perl Documentation, and it’s here to save you from a truly iconic typo.

πŸ’… NAME πŸ’…

Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames β€” don’t use labels that are the same as the special block names. periodt.

🫢 AFFILIATION 🫢

This Policy is part of the core Perl::Critic distribution. no cap.

✨ DESCRIPTION ✨

okay so when you’re using one of the special Perl blocks β€” BEGIN, END, CHECK, INIT, and UNITCHECK β€” it is easy to mistakenly add a colon to the end of the block name. literally so easy. E.g.:

# a BEGIN block that gets executed at compile time.
BEGIN { <...code...> }

# an ordinary labeled block that gets executed at run time.
BEGIN: { <...code...> }

The labels BEGIN:, END:, etc. are probably errors. 🚨 This policy prohibits the special Perl block names from being used as labels. periodt.

πŸŽ€ CONFIGURATION πŸŽ€

This Policy is not configurable except for the standard options. that’s it, bestie πŸ’….

🌈 SEE ALSO 🌈

The Perl Buzz article on this issue at http://perlbuzz.com/2008/05/colons-invalidate-your-begin-and-end-blocks.html. iykyk.

πŸ’– ACKNOWLEDGMENT πŸ’–

Randy Lauen for identifying the problem. 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Mike O’Regan. πŸ‘‘

Copyright (c) 2008-2011 Mike O’Regan. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


later bestie, and remember: this page is perl v5.42.0, dated 2024-10-23, and its manual name is Perl::...kNames(3pm). πŸ’–βœ¨

πŸ“¦ where this page comes from