in reply to Re^2: Annoying 'Use of uninitialized value in concatenation' warning
in thread Annoying 'Use of uninitialized value in concatenation' warning

The problem with using the  || (logical-or) operator (see perlop) in this case is that the undefined value is false, as are 0, '0' and '' (the empty string), and  || does not distinguish. If your Perl version is 5.10+, you can use the  // (defined-or) operator; otherwise, you're stuck with syntax that's a bit more messy:

c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; my @ra = (0, 0, 0); ;; my $i = 1; print qq{value at index $i: }, $ra[$i] || 'undef'; print qq{value at index $i: }, $ra[$i] // 'undef'; print qq{value at index $i: }, defined($ra[$i]) ? $ra[$i] : 'undef' " value at index 1: undef value at index 1: 0 value at index 1: 0


Give a man a fish:  <%-(-(-(-<