I quite liked this problem at first, and like TheoPetersen my reaction was to try unpack and map. Adding unpack was easy, and I even squeezed in a map or two, but not avoiding a for loop. Now the strange thing is that all my efforts are actually slower than rbi's original. I'll add code if anyone wants but it's basically what was posted here:

Alba_1 is almost exactly TheoPetersen's solution (I didn't bother posting after seeing his)
Alba_2 is a variant that does the unpacking this way:

my @fractions = unpack('A5'x$nt, substr($record, 0, 5*$nt)); my @exps = unpack('A2'x$nt, substr($record, 5*$nt, 2*$nt));
rbi_fortran is rbi's code (though made strict compliant). And the result are (based on 7 fields in $record):
Benchmark: running Alba_1, Alba_2, rbi_fortran, each for at least 5 CP +U seconds... Alba_1: 6 wallclock secs ( 5.31 usr + 0.00 sys = 5.31 CPU) @ 39 +94.16/s (n=21217) Alba_2: 6 wallclock secs ( 5.41 usr + 0.00 sys = 5.41 CPU) @ 47 +89.68/s (n=25893) rbi_fortran: 5 wallclock secs ( 5.26 usr + 0.00 sys = 5.26 CPU) @ 5 +211.78/s (n=28266)
So what gives? I could have sworn unpack was faster. One thing I tried is the effect of the number of fields to extract, so here it is with 28 fields in $record:
Benchmark: running Alba_1, Alba_2, rbi_fortran, each for at least 5 CP +U seconds... Alba_1: 5 wallclock secs ( 5.39 usr + 0.00 sys = 5.39 CPU) @ 12 +14.06/s (n=6545) Alba_2: 6 wallclock secs ( 5.41 usr + 0.00 sys = 5.41 CPU) @ 14 +25.64/s (n=7707) rbi_fortran: 5 wallclock secs ( 5.37 usr + 0.00 sys = 5.37 CPU) @ 1 +540.09/s (n=8278)
Basically no effect. Any other ideas?

--
I'd like to be able to assign to an luser


In reply to Re: how can I speed this up? by Albannach
in thread how can I speed this up? by rbi

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.