in reply to Simple line parse question

Can anyone tell be a better/faster way to do this?

To me "better" means more clear. The number one goal of software should be clarity..."hey, is it easy to understand what this code does?"

Performance is usually a secondary goal. However strange as it may be, if your code is clear, you will often achieve high performance.

Search for "benchmark" and you will find ways to measure the performance of version X vs Y.

Your code:
join("", (split(" ", $line, 5))[2,3])
is not easy to understand. Do not mistake fewer lines as meaning higher performance.

I think the following is clear and works well. Don't be shy about giving some intermediate variable a name.

#!/usr/bin/perl -w use strict; my $input = "a b c d e f g"; my @words = split(/\s+/,$input); print @words[2,3], "\n"; __END__ Prints: cd