use Text::Abbrev;
%hash = ();
abbrev(*hash,
LIST
);
The
abbrev()
routine takes each string in
LIST
and
constructs all unambiguous abbreviations (truncations) of the string
with respect to the other strings in
LIST
. Each such truncation
(including the null truncation consisting of the entire string) is used as
a key in
%hash
for which the associated value is the non-truncated
string.
So, if
good
is the only string in
LIST
beginning with
g
, the following key/value pairs will be created:
g => good,
go => good,
goo => good,
good => good
If, on the other hand, the string
go
is also in the list, then
good
yields these key/value pairs:
goo => good,
good => good
and
go
yields only:
go => go