waytoperl has asked for the wisdom of the Perl Monks concerning the following question:
Performing numeric compare in an if statement
while (<$FILE> { chomp; my ($number1,$number2,$number3,$number4) = split /\t/; print "$number4\n"; if ($number4 == 1,2) { print "$number4 good\n"; } else { print "$number4 bad\n"; } }
I've correct result, but there are warnings
Useless use of numeric eq <==> in void context at .... Argument "1,2" isn't numeric in numeric eq <==> at .... 1,2 good
If I replace "==" with "eq" then i've warning and only 1 get printed. Expected output is 1,2 good
useless use of string eq in void context at .... 1 good
If I replace "eq" with "=" then i've no warning and only 1 get printed. Expected output is 1,2 good
1 goodDon't understand what's wrong. Please help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl compare
by davido (Cardinal) on Sep 26, 2014 at 02:30 UTC | |
by waytoperl (Beadle) on Sep 26, 2014 at 04:25 UTC | |
|
Re: Perl compare ( numeric in void isn't numeric)
by Anonymous Monk on Sep 26, 2014 at 01:05 UTC | |
by waytoperl (Beadle) on Sep 26, 2014 at 04:18 UTC | |
by choroba (Cardinal) on Sep 26, 2014 at 13:36 UTC | |
by GotToBTru (Prior) on Sep 26, 2014 at 14:33 UTC | |
|
Re: Perl compare
by Jenda (Abbot) on Sep 26, 2014 at 10:02 UTC | |
|
Re: Perl compare
by Random_Walk (Prior) on Sep 26, 2014 at 14:18 UTC | |
|
Re: Perl compare
by Anonymous Monk on Sep 26, 2014 at 15:34 UTC | |
by waytoperl (Beadle) on Sep 26, 2014 at 19:26 UTC |