in reply to Perl compare

Don't understand what's wrong. Please help!

There are checklists for that , Basic debugging checklist

Work through the list, turn on diagnostics, read the more verbose error message, use Deparse to see how perl parses your code

"1,2" is not "a number" or "a string" , its "a list", its two numbers seperated by the comma operator

  • Comment on Re: Perl compare ( numeric in void isn't numeric)

Replies are listed 'Best First'.
Re^2: Perl compare ( numeric in void isn't numeric)
by waytoperl (Beadle) on Sep 26, 2014 at 04:18 UTC
    "1,2" is not "a number" or "a string" , its "a list", its two numbers separated by the comma operator

    it's a list

    my ($num1,$num2) = split (',',$number4); if ($num1 == 1 && $num2 == 2) {....

    above code have no warning

      It seems $number4 is not a list, it's a string. So, use string comparison eq and quote the string literals:
      if ($number4 eq '1,2') { # ... }
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      No, a scalar can not be a list. It is a string containing two digits separated by a comma.

      1 Peter 4:10