<?xml version="1.0" encoding="windows-1252"?>
<node id="959044" title="Re: hash array" created="2012-03-11 18:57:18" updated="2012-03-11 18:57:18">
<type id="11">
note</type>
<author id="959034">
wamos</author>
<data>
<field name="doctext">
Try this ...

&lt;code&gt;
my %dictionary;

readWords(\%dictionary);
sortDictionary(\%dictionary);

sub readWords {
   $numWords = 0;

   open FILE, $ARGV[0] or die $!;

   while (my $lines = &lt;FILE&gt;) {
      $numWords++;
      chomp $lines;

      my ($words, $definitions) = split('/', $lines);
      $words = lc($words);
      $dictionary{$words} = $definitions;
   }
   foreach $words (keys(%dictionary)) {
      print "$words = ",$dictionary{$words},"\n";
   }
   close FILE;
}

sub sortDictionary {
   foreach my $key (sort keys %dictionary) {
      $key =~ /^(.)/;
      my $line = $key . '/' . $dictionary{$key} . "\n";
      print $line;
   }
}
&lt;/code&gt;

Hope that does what you want

&lt;code&gt;
C:\&gt; x.pl x.txt
cat = nice animal
snake = nasty animal
dog = best friend
cat/nice animal
dog/best friend
snake/nasty animal
&lt;/code&gt;</field>
<field name="root_node">
959040</field>
<field name="parent_node">
959040</field>
</data>
</node>
