my %dictionary; readWords(\%dictionary); sortDictionary(\%dictionary); sub readWords { $numWords = 0; open FILE, $ARGV[0] or die $!; while (my $lines = <FILE>) { $numWords++; chomp $lines; my ($words, $definitions) = split('/', $lines); $words = lc($words); $dictionary->{$words} = $definitions; } foreach $key (%dictionary) { print $dictionary->{$words}; print $result . "\n"; } close FILE; } sub sortDictionary { foreach my $key (sort keys %{dictionary}) { $key =~ /^(.)/; my $line = $key . '/' . $dictionary->{$key} . "\n"; print $line; } }
In reply to hash array by borovez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |