Thanks for comments.

My goal is basically to achieve similar timing to the following in awk:

echo "a b c d e f g" | awk '{print $3$4}'

I find it hard to believe that my split&join solution is the fastest perl has to offer to achieve this. This one little line of code in my script is actually turning out to be quite the performance hotspot. So i thought, why not ask here to see if there's a faster way that i'm unaware of. I've already try the following, but they're all slower than my split&join:

1: ... | perl -ne 'printf("%s%s", (split(" ", $_, 5))[2,3]);' 2: ... | perl -ne 'print /(?:\S+ ){2}(\S+) (\S+)/ 3: ... | perl -ane 'print "$F[2]$F[3]";' 4: I even wrote my own subroutine using index/substr to extract what i + need ...

I guess i'm hoping someone will introduce me to a new technique. We can't let the awk'ers have this one so easily can we?


In reply to Re: Simple line parse question by jimmy.pl
in thread Simple line parse question by jimmy.pl

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.