Locale::Object::DB - do database lookups for Locale::Object modules
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'; my $results = $db->lookup( table => $table, result_column => $result_column, search_column => $what, value => $value ); foreach my $item (@{$results}) { print $item->{$result_column}; } $result = $db->lookup_dual( table => $table, result_col => $result_column, col_1 => $first_search_column, val_1 => $first_search_value, col_2 => $second_search_column, val_2 => $second_search_value );
lookup()
$db->lookup( table => $table, result_column => $result_column, search_column => $search_column, value => $value );
lookup will return a reference to an anonymous array of hashes. The hashes will contain the 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. Use '*' as a value for result_column if you want to retrieve whole rows.
lookup
For information on what db tables are available and where the data came from, see docs/database.pod.
docs/database.pod
IMPORTANT: The way of using this method has changed as of version 0.2, and in addition it supersedes the place formerly taken by lookup_all(). Apologies for any inconvenience.
lookup_all()
lookup_dual()
my $result = $db->lookup_dual( table => $table, result_col => $result_column, col_1 => $first_search_column, val_1 => $first_search_value, col_2 => $second_search_column, val_2 => $second_search_value );
lookup_dual will return a reference to an anonymous array of hashes. The hashes will contain the results for a query of the database for cells in $result_column in $table that are in a row that has two specified values in two specified columns. Use '*' as a value for $result_column if you want to retrieve whole rows.
lookup_dual
$result_column
$table
The database file itself is named locale.db and must reside in the same directory as this module. If it's not present, the module will croak with a fatal error.
locale.db
Originally by Earle Martin
Originally by Earle Martin. To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
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.