in reply to Which is better when doing a simple match?

Well, they aren't actually the same thing.... Your second one will match strings such as 'clothing' and and 'Worthington' whereas the first one obviously wont. (which answers the 'accurate' part of your question <doh>)

Still its a moot point. 'eq' wins hands down over the equivalent anchored regex, i.e. $thing =~ /^thing$/. Its faster, cleaner, and easier to debug....

-Blake

Replies are listed 'Best First'.
Re: Re: Which is better when doing a simple match?
by Cine (Friar) on Aug 21, 2001 at 23:48 UTC
    if (index $thing,'thing' != -1)
    will do that same as
    if ($thing =~ /thing/)


    T I M T O W T D I