Locale::Object::DB - do database lookups for Locale::Object modules
0.1
This module provides common functionality for the Locale::Object modules by doing lookups in the database that comes with them (which uses DBD::SQLite).
use Locale::Object::DB; my $db = Locale::Object::DB->new(); my $table = 'country'; my $what = 'name'; my $value = 'Afghanistan'; my @results = $db->lookup($table, $what, $value); my %countries; $table = 'continent'; my $result_column = 'country_code'; foreach my $result ( $db->lookup_all( table => $table, result_column => $result_column, search_column => $what, value => $value) ) { # fill up %countries with countries in the same continent as $value $countries{$result} = 1; }
$db->lookup($table, $what, $value);
lookup will return an array of results from a query of the database for a row matching the table name, column name and cell value that you specify. If no match was found, a message saying so will be returned. Any NULL values in matching rows will be returned in the results as UNDEF.
lookup
$db->lookup_all( table => $table, result_column => $result_column, search_column => $search_column, value => $value );
lookup_all will return an array of results for a query of the database for cells in $result_column in $table that are in a row that has $value in $search_column.
lookup_all
For information on what db tables are available and where the data came from, see Locale::Object::DB::Schemata.
Because the database file isn't a Perl file, Module::Build won't copy it into the blib directory at the ./Build test stage, and To get around this, Locale::Object::DB installs the database into the same directory as itself, and makes a symlink to the database in /tmp (unless one exists already) which the
./Build test
Locale::Object::DB
Earle Martin <EMARTIN@cpan.org>
See the credits for Locale::Object.
Copyright 2003 Fotango Ltd. All rights reserved. http://opensource.fotango.com/
This module is released under the same license as Perl itself, and is provided on an "as is" basis. The author and Fotango Ltd make no warranties of any kind, either expressed or implied, as to the accuracy and/or utility of any results obtained from its use. However, if you do find something wrong with the results, please let the author know. Thanks.
To install Locale::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Object
CPAN shell
perl -MCPAN -e shell install Locale::Object
For more information on module installation, please visit the detailed CPAN module installation guide.