#!/usr/bin/perl
######################################
# Usage:  ./anagrams
#
# See "Programming Pearls" pg 15.
#
# At this point (r347) all it does is read each word in a big dictionary.
# What would just this much look like in C or C++ ?
# 
# $Id: anagrams.pl 2629 2006-08-02 20:11:31Z mahoney $
########################################################
use strict;
use warnings;
use IO::All qw(io);

my $filename = '/usr/share/dict/words';   # Set this to '-' to read from STDIN.
my $input = io($filename);                

print "Processing '$filename'.\n";

# Get one line (word) at a time, lower case, without trailing newline.
my $line_number = 0;
while (chomp(my $word = lc $input->getline)){
  $line_number++;
  print "  $word \n" if $line_number < 10;
  print "  ... \n"   if $line_number == 10;

  # ... do something to each word here ...
}

print "Done.  Number of words is $line_number. \n";



