The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hints - Perl extension for hints databases

SYNOPSIS

        use Hints;

        my $hints = new Hints;

        $hints->load_from_file('my.hints');

        print $hints->random();

DESCRIPTION

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.

THE HINTS CLASS

new

Constructor create instance of Hints class. Than call init() constructor for build implicit database (descendant ussually re-implement these method).

        my $hints = new Hints;

init

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.

load_from_file (FILE, SEPARATOR)

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**$');

clear

This method clear hints database.

        $hints->clear;

format

Method is used for formatting hint before returning. Ussually redefined by descendant. In abstract class making one long line from multilines.

first

Return first hint from database.

        my $hint = $hints->first;

next

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);

random

Return random hint from database.

        my $hint = $hints->random;

count

Return number of hints in database.

        my $number = $hints->count;

item NUMBER

Return NUMBER. item from database.

        # return last hint
        my $hint = $hints->item($hints->count - 1);

forward

Return next hint after last wanted hint from database.

        my $random_hint = $hints->random;
        my $next_hint   = $hints->forward;

backward

Return previous hint before last wanted hint from database.

        my $random_hint = $hints->random;
        my $prev_hint   = $hints->backward;

VERSION

0.02

AUTHOR

(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.

SEE ALSO

perl(1), svplus(1), Hints::Base(3), Hints::Base::svplus(3).