NAME
Data::Phrasebook - Abstract your queries!
SYNOPSIS
use Data::Phrasebook;
my $q = Data::Phrasebook->new(
class => 'Plain',
loader => 'Text',
file => 'phrases.txt',
);
$q->delimiters( qr{ \[% \s* (\w+) \s* %\] }x );
my $phrase = $q->fetch($keyword);
DESCRIPTION
This is a factory class for accessing phrasebooks.
To explain what phrasebooks are it is worth reading Rani Pinchuk's (author of Class::Phrasebook) article of Perl.com:
http://www.perl.com/pub/a/2002/10/22/phrasebook.html
Common uses of phrasebooks are in handling error codes, accessing databases via SQL queries and written language phrases. Examples are the mime.types file and the hosts file, both of which use a simple phrasebook design.
Unfortunately Class::Phrasebook is a complete work and not a true class based framework. If you can't install XML libraries, you cannot use it. This distribution is a collaboration between Iain Truskett and myself to create an extendable and class based framework for implementing phrasebooks.
Note that if using an implementation that supports dictionaries, they cannot be changed once the loader class is instantiated. This may change in the future.
DEDICATION
Much of the work original class framework is from Iain's original code. My code was alot simpler and was tied to using just an INI data source. Merging all the ideas and code together we came up with this distribution.
Unfortunately Iain died in December 2003, so he never got to see or play with the final working version. I can only thank him for his thoughts and ideas in getting this distribution into a state worthy of release.
Iain Campbell Truskett (16.07.1979 - 29.12.2003)
CONSTRUCTOR
new
The arguments to new depend upon the exact class you're creating.
The default class is Plain
.
The class
argument defines the class type you wish to utilise. Currently there are Plain
and SQL
classes available. The class
argument is treated like this, using Foobar
as the sample value:
If you've subclassed
Data::Phrasebook
, for example asDictionary
, thenDictionary::Foobar
is tried.If that failed,
Data::Phrasebook::Foobar
is tried.If that failed,
Foobar
is tried.If all the above failed, we croak.
This should allow you some flexibility in what sort of classes you use while not having you type too much.
For other parameters, see the specific class you wish to instantiate. The class argument is removed from the arguments list and the new
method of the specified class is called with the remaining arguments.
SEE ALSO
Data::Phrasebook::Plain, Data::Phrasebook::SQL, Data::Phrasebook::SQL::Query, Data::Phrasebook::Debug, Data::Phrasebook::Generic, Data::Phrasebook::Loader, Data::Phrasebook::Loader::Text, Data::Phrasebook::Loader::Base.
SUPPORT
Please see the README file.
AUTHOR
Original author: Iain Campbell Truskett (16.07.1979 - 29.12.2003)
Maintainer: Barbie <barbie@cpan.org> since January 2004.
LICENCE AND COPYRIGHT
Copyright (C) Iain Truskett, 2003. All rights reserved.
Copyright (C) Barbie, 2004-2005. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
The full text of the licences can be found in the Artistic and COPYING files included with this module, or in perlartistic and perlgpl in Perl 5.8.1 or later.