>>>>> "NT" == Nathan Torkington <[EMAIL PROTECTED]> writes:

>> Would it be reasonable to ask that passing undef into the offset
>> or start of substr have substr return an undef?

NT> Wouldn't you get a warning anyway, if you were treating undef like
NT> a number?

Aha, but I don't want a warning, I want the code to 'fail' reasonably.

Somehow I find
        if (40 == ($foo = substr($bar, index($bar, 'xyz')))) {
        }

much nicer than

        if (defined ($offset = index($bar, 'xyz')) &&
                (40 == substr($bar, $offset))) {
        }

I use this style of safe failure when working in SQL.

<chaim>
-- 
Chaim Frenkel                                        Nonlinear Knowledge, Inc.
[EMAIL PROTECTED]                                               +1-718-236-0183

Reply via email to