October 2021 Archives

My Favorite Warnings: redefine

Sooner or later any programmer, writing in any language, will run across something like this Perl warning: Subroutine foo redefined. This is telling you that somehow, somewhere, you tried to create two subroutines with the same name.

Tracking this down can be tricky, and remediation equally so. The possibilities include:

  • If one of your own subroutines is involved, you can rename it.
  • If an imported subroutine that you do not need is involved, you can just not import it. This, of course, involves figuring out which imports …

My Favorite Modules: diagnostics

One of the things the Perl 5 Porters work hard on is issuing diagnostics that are actually diagnostic. I think they do a pretty good job at this, but sometimes I need a bit more explanation than the typical one-line message.

Now, there is documentation on all of these in perldiag, but paging through that looking for my message is a pain.

Fortunately, there is a module for that: diagnostics. This module cause…

My Favorite Warnings: uninitialized

This warning was touched on in A Belated Introduction, but I thought it deserved its own entry.

When a Perl scalar comes into being, be it an actual scalar variable or an array or hash entry, its value is undef. Now, the results of operating on an undef value are perfectly well-defined: in a nuneric context it is 0, in a string context it is '', an…

My Favorite Warnings — A Belated Introduction

Look, that's why there's rules, understand? So that you think before you break 'em. — Terry Pratchett, in Thief of Time.

A couple installments into this series of blog posts, I realized an introduction to Perl warnings would be appropriate, with some words on how to turn them off, and why you probably do not want to. Yes, this should have been the first post in the series, but I didn't know it would actually be a series, and, well, maybe better late than never.

The Perl compiler/interpreter can emit warnings when it finds…

About Tom Wyant

user-pic I blog about Perl.