in reply to Re: advice on improving performance of this code
in thread advice on improving performance of this code
Update
Upon testing $, tests 25% faster that join in the best case to 50% SLOWER in many cases! Presumably it relates to being faster to pass one argument to print (after the join) rather than many. Suprised me. Credit gjb for this pickup. I will be using join in future
You can set $, to ' ' and ditch the join as well which will be faster again. Manipulating $, and $" can often useful in controlling output. local ensures no suprises elsewhere in the code.
{ local $, = ' '; print @{$_}[0..4], "\n" for @Data; }
Note that setting $, and doing it in one line like this has the side effect of adding a ' ' after the last element and before the "\n". This can be rectified with a separate call to print for the "\n" if required. print() is actually quite slow so it may be faster to do this:
{ local $, = ' '; print @$_[0..3], $$_[4] ."\n" for @Data; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|