title: words count example in Scala?
body: <p>I see a lot of Scala tutorials with examples doing things like recrursive traversals or solving math problems. In my daily programming life I have the feeling most of my coding time is spent on mundane tasks like string manipulation, database queries and date manipulations. Is anyone interested to give an example of the a Scala version of the following perl script?</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  #opens a file with on each line one word and counts the number of occurrences 
  # of each word, case insensitive
  print "Enter the name of your file, ie myfile.txt:\n";
  my $val = &lt;STDIN&gt;;
  chomp ($val);
  open (HNDL, "$val") || die "wrong filename";
  
  my %count = ();
  while ($val = &lt;HNDL&gt;)
  {
          chomp($val);
      $count{lc $val}++;
  }
  close (HNDL);
  
  print "Number of instances found of:\n";
  foreach my $word (sort keys %count) {
          print "$word\t: " . $count{$word} . " \n";
  }
  </code></pre>
  
  <p>In summary:</p>
  
  <ul>
  <li>ask for a filename</li>
  <li>read the file (contains 1 word per line)</li>
  <li>do away with line ends  ( cr, lf or crlf)</li>
  <li>lowercase the word</li>
  <li>increment count of the word</li>
  <li>print out each word, sorted alphabetically, and its count  </li>
  </ul>
  
  <p>TIA</p>