And yes, I was sort of expecting unpack() to be faster, but it is still better to try it to be sure.

Indeed. I certainly didn't mean to suggest your benchmark test wasn't a splendid idea. I only meant that, in this case, the outcome of the benchmark test was consistent with one's rational expectation based on one's understanding of unpack() and its raison d'être. After all, the Perl FAQ states:

C:\>perldoc -q fixed | head -5 Found in C:\strawberry\perl\lib\perlfaq5.pod How can I manipulate fixed-record-length files? The most efficient way is using pack() and unpack(). This is faste +r than using substr() when taking many, many strings. It is slower for ju +st a few. C:\>

Jim


In reply to Re^4: Performance problems on splitting long strings by Jim
in thread Performance problems on splitting long strings by Laurent_R

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.