in reply to == and != don't work as expected

My bad. I should have posted a coded example.

I was confused when 'two' != 'one' returned a false value in my program. I agree that 'two' == 'two' returns a true value.

I understand that this semantics is consistent.

When developing a complex Perl program, I would prefer for 'two' != 'one' to die, rather than return false. IMHO, the current behavior is not always desirable.

Sorry.

Replies are listed 'Best First'.
Re^2: == and != don't work as expected
by davorg (Chancellor) on Aug 09, 2004 at 15:37 UTC

    Are you sure that you don't just want the string comparison operators - eq, ne, etc?

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^2: == and != don't work as expected
by PodMaster (Abbot) on Aug 09, 2004 at 17:12 UTC
    So use fatal warnings instead. `perldoc perllexwarn'
    C:\>perl -Mwarnings=FATAL,all -e"print 1 if shift == shift" foo foo Argument "foo" isn't numeric in numeric eq (==) at -e line 1. C:\>perl -we"print 1 if shift == shift" foo foo Argument "foo" isn't numeric in numeric eq (==) at -e line 1. Argument "foo" isn't numeric in numeric eq (==) at -e line 1. 1

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re^2: == and != don't work as expected
by TomDLux (Vicar) on Aug 10, 2004 at 01:17 UTC

    The numeric value of the string "two" is zero (0)

    The numeric value of the string "one" is zero (0)

    Comparing the numeric values of the two strings, "two" and "one", shows they have the same numeric value. This is identical to the numeric value of "potato" ( and even of "potatoe" ), "Zambia", "infinity" and "TomDLux".

    If you want to compare the strings, use '=='. If you want to use numeric comparisons on strings, make sure they contain numbers.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA