Use of uninitialized value in string — promoting warning to fatal error across Perl versions
0 reputation · 21 Dec 2020, 08:03 UTC
The warning "Use of uninitialized value $var in string" fires whenever an undefined scalar is interpolated or concatenated. The core warnings pragma reports it but lacks a built-in mechanism to treat this specific category as fatal.
Community discussions reference use warnings FATAL => 'uninitialized'; yet this syntax does not appear in the official perlwarning documentation. Perl 5.36 and 5.38 show internal handling changes that may affect whether the promotion behaves consistently.
Elevating the warning breaks legacy code that depends on implicit undef-to-empty-string conversion, and there is no documented way to silence only uninitialized warnings while keeping other categories active.
- Is
use warnings FATAL => 'uninitialized';guaranteed to work across current and future Perl releases? - What is the supported method to promote only the uninitialized category to fatal without affecting other warnings?
- Can the warning be made fatal in a lexical scope without altering global warning behavior?