Norman Gaywood wrote:
Oddly, perl very rarely wins these. ;-)
This must come close:
perl -00 -ne 'print tr/,//' input.txt
Timing test: say the above takes time 1.0
then the following takes time 0.46 ...
python -Sc "import sys; print sys.stdin.read().count(',')"
both are much much faster than a sequence of pipes and
low-level shell utils. And easier to comprehend.
IMHO, the most important part of optimisation these days
is comprehensibility: people power costs a lot more than
CPU and disks power.
I nominate the perl soln as the winner so far: runs like
a bat of out hell and is the most easy to understand.
And the shortest in source code size.
cheers
rickw
--
_________________________________
Rick Welykochy || Praxis Services
People who enjoy eating sausage and obey the law should not watch either being
made.
-- Otto von Bismarck
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html