Hints - Perl extension for hints databases
use Hints; my $hints = new Hints; $hints->load_from_file('my.hints'); print $hints->random();
In many programs you need hints database and methods for accessing this database. Extension Hints is object oriented abstract module, you can use file-base of hints or make descendant with own base.
Constructor create instance of Hints class. Than call init() constructor for build implicit database (descendant ussually re-implement these method).
init()
my $hints = new Hints;
This method was called from new() constructor for building implicit database. Base class define only abstract version. Return value of init() method must be instance (typically same as calling instance). You can use this to change class or stop making instance by returning of undefined value.
new()
Loading all hints from file specified as first argument. Hints separator is determined by second argument. If separator is undefined than default separator is used (^---$). Separator argument is regular expression.
You can also use file handle or reference to array instead of filename.
$hints->load_from_file('my.hints','^**SEPARATOR**$'); $hints->load_from_file(\*FILE,'^**SEPARATOR**$'); $hints->load_from_file(\@lines,'^**SEPARATOR**$');
This method clear hints database.
$hints->clear;
Method is used for formatting hint before returning. Ussually redefined by descendant. In abstract class making one long line from multilines.
Return first hint from database.
my $hint = $hints->first;
Return next hint from database (used after first). If no hint rest undefined value is returned.
my $hint = $hints->first; do { print $hint."\n"; } if (defined $hint = $hints->next);
Return random hint from database.
my $hint = $hints->random;
Return number of hints in database.
my $number = $hints->count;
Return NUMBER. item from database.
# return last hint my $hint = $hints->item($hints->count - 1);
Return next hint after last wanted hint from database.
my $random_hint = $hints->random; my $next_hint = $hints->forward;
Return previous hint before last wanted hint from database.
my $random_hint = $hints->random; my $prev_hint = $hints->backward;
0.02
(c) 2001 Milan Sorm, sorm@pef.mendelu.cz at Faculty of Economics, Mendel University of Agriculture and Forestry in Brno, Czech Republic.
This module was needed for making SchemaView Plus (svplus) for making user-friendly interface.
svplus
perl(1), svplus(1), Hints::Base(3), Hints::Base::svplus(3).
To install Hints, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hints
CPAN shell
perl -MCPAN -e shell install Hints
For more information on module installation, please visit the detailed CPAN module installation guide.