Book HomeJava and XSLTSearch this book

8.204. Text::Abbrev

Given a list of strings, creates a hash of unambiguous abbreviations. Exports one function.

abbrev

abbrev (\%hashref, list)

Takes each string in list and constructs the hash referenced by \%hashref. Each key is an unambiguous truncation of one of the strings, and the value is the full string (in which unambiguous means that there is only one possible expansion that matches one of the strings in the list). For example, if list contains "file" and "find", then the key/value pairs created include:

fil  => file
file => file
fin  => find
find => find

Both "f" and "fi" are ambiguous, since they start both words, and therefore, they don't appear as keys.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.