On Thu, 19 Dec 2002 17:03:20 -0500,
perl-qotw-discuss-ZxR0713JXSrQT0dZR+AlfA@xxxxxxxxxxxxxxxx wrote:
>
>'spel' will be given one or more dictionaries of words that are
>already spelled correctly. It will always try to read the file
>'/usr/dict/words'. It will also try to read '.spel' files from
>certain directories. If the user has set an environment variable
>SPELWORDS, 'spel' should interpret its value as a :-separated list of
>directories to be searched for '.spel' files. If no SPELWORDS
>variable is set, 'spel' should search in the user's home directory and
>in the current directory.
Here's an attempt at a portable implementation of the above. Any
comments?
use Config '%Config';
use File::Spec::Functions qw/catfile curdir rootdir/;
sub readdict {
# N.B. The concept of 'home directory' is non-portable, but we
# will feed a "~/*.spel" to glob and see if it returns anything.
#
# path_sep may not be set (which is a bug in those perl ports).
local @ARGV = (catfile(rootdir, qw/usr dict words/),
map glob(catfile($_, '*.spel')),
(exists $ENV{SPELWORDS}
? split($Config{path_sep}||':', $ENV{SPELWORDS})
: ("~", curdir)));
print join "\n", "Using dictionaries:", @ARGV, "";
while (<>) {
chomp;
...
}
}
|