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?)
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: if-elsif weirdness
by hossman (Prior) on May 21, 2003 at 07:03 UTC | |
Re: if-elsif weirdness
by Zaxo (Archbishop) on May 21, 2003 at 05:12 UTC | |
by leriksen (Curate) on May 21, 2003 at 05:32 UTC | |
Re: if-elsif weirdness
by graff (Chancellor) on May 21, 2003 at 05:32 UTC | |
Re: if-elsif weirdness
by Abigail-II (Bishop) on May 21, 2003 at 12:51 UTC | |
Re: if-elsif weirdness
by japhy (Canon) on May 21, 2003 at 15:36 UTC |
Back to
Seekers of Perl Wisdom