http://www.perlmonks.org?node_id=259638

leriksen has asked for the wisdom of the Perl Monks concerning the following question:

A looonnnggg time ago somebody noted this
well I just wasted an hour with the same, but I can add that it works OK on our Solaris 5.005, but not RH 5.6.0 or RH 5.6.1 - no idea on 5.8 (anyone?)
#!/usr/bin/perl -w use strict; my $string = "ABC"; my $value = undef; if ($string =~ qr(DEF)) { # warning reported here } elsif ($string =~ qr(GHI)) { } elsif ($value/1000 ne $value) { # warning actually here } else { }

Use of uninitialized value in division (/) at E:\src\perl\error.pl line 5.

Use of uninitialized value in string ne at E:\src\perl\error.pl line 5.

now, apart from long chains of if-elsif's being a pain and possibly a sign of poor design or implementation, we all know perfectly well that we all do it all the time - so is there a way to 'nudge' perl into reporting the correct line in the warning? Or would I be better off using some switch/case variant from now on?