September 2021 Archives

My Favorite Warnings: exiting

Perl has various ways to transfer control out of the normal flow: die(), goto(), return(), next, last, and redo are among the sorts of things I mean. Not all of these are suitable for all circumstances, and Perl issues an exiting warning for unsuitable cases.

Sometimes, though, you just ne…

My Favorite Modules: if

My blog post My Favorite Warnings: redundant and missing touched on the use of the if module. Comments on that post made me think it deserved a top-level treatment, expanding on (though not necessarily improving on) Aristotle's comment.

The ="prettyp…

My Favorite Warnings: redundant and missing

The redundant and missing warnings were added in Perl 5.22 to cover the case where a call to the printf or sprintf had more (redundant) or fewer (/users/tom_wyant/2021/09/index.html

My Favorite Warnings: once

The Perl compiler wants to help us write clean code. One of the ways that it does this is to issue warnings when a global variable appears ony once: Name "main::Foo" used only once: possible typo at ...

The thing is, sometimes this is not an error. For example, we may want to refer to a global variable in another package, one that was not imported into our namespace.

I have seen various expedients used to avoid this warning in CPAN code. Something like $Foo::Bar = $Foo::Bar = 42; is fairly typical. Sometimes thi…

About Tom Wyant

user-pic I blog about Perl.