you should look at use Benchmark;

however, a direct compare should definately be faster than a regexp match,
if fo not other reason than perl does not need to incur the overhead 
involved with making a regexp match, simple or not.

On Mon, Jul 22, 2002 at 01:35:21PM -0700, Palit, Nilanjan wrote:
> If I'm doing an exact match, which is faster: a regexp match or a string
> compare. In other words, which one of the following two is faster, or are
> they comparable?
> 
> A. if ($string =~ /^pattern$/) ...
> B. if ($string eq "pattern") ...
> 
> Does the length of the pattern matter?
> 
> Thanks,
> 
> -Nilanjan
> 

-- 
 ___  __  __    __  _  _  ____    _  _  ____  ____ 
/ __)(  )(  )  /__\( \/ )( ___)  ( \( )( ___)(_  _)
\__ \ )(__)(  /(__)\\  /  )__)    )  (  )__)   )(  
(___/(______)(__)(__)\/  (____)()(_)\_)(____) (__) 
Don't play "stupid" with me.  I'm better at it!

Reply via email to