Unless you are doing this thousands of times, it will hardly matter which one is faster.

If you must know, you can always use the Benchmark module, and run a simple test:

#!/usr/bin/perl use strict; use warnings; use Benchmark 'cmpthese'; our $item = '"path/path1==new'; cmpthese(-1, { method1 => 'my ($epath, $relt) = split /==/, $item', method2 => 'my ($epath, $relt) = $item =~ /([^=]*)==(.*)/', }); __END__ Rate method2 method1 method2 334042/s -- -38% method1 535924/s 60% --
Method 1 will about 1.1 microseconds faster (at least, on my box). So, if I have a million of them, method1 will gain 1 second over method2. That's hardly worth the trouble.

I'd pick method1 because, IMO, it's more clear to see what it does.

Oh, and both methods use a regular expression anyway.

Perl --((8:>*

In reply to Re: Performace calculation by Perl Mouse
in thread Performace calculation by anniyan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.