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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |