borovez has asked for the wisdom of the Perl Monks concerning the following question:
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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash array
by repellent (Priest) on Mar 11, 2012 at 22:59 UTC | |
|
Re: hash array
by aaron_baugher (Curate) on Mar 12, 2012 at 00:51 UTC | |
|
Re: hash array
by wamos (Initiate) on Mar 11, 2012 at 22:57 UTC | |
|
Re: hash array
by wamos (Initiate) on Mar 11, 2012 at 22:59 UTC | |
by borovez (Initiate) on Mar 11, 2012 at 23:20 UTC |