NAME
WWW::CIA::Source::Web - an interface to the online CIA World Factbook
SYNOPSIS
use WWW::CIA::Source::Web;
my $source = WWW::CIA::Source::DBM->new();
DESCRIPTION
WWW::CIA::Source::Web is an interface to the live, online version of the CIA World Factbook.
It's a very slow way of doing things, but requires no pre-compiled DBM. It's more likely to be useful for proving concepts or testing.
METHODS
Apart from new
, these methods are normally accessed via a WWW::CIA object.
new()
-
This method creates a new WWW::CIA::Source::Web object. It takes no arguments.
value($country_code, $field)
-
Retrieve a value from the web.
$country_code
should be the FIPS 10-4 country code as defined in http://www.cia.gov/cia/publications/factbook/appendix/appendix-d.html.$field
should be the name of the field whose value you want to retrieve, as defined in http://www.cia.gov/cia/publications/factbook/docs/notesanddefs.html. (WWW::CIA::Parser also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country respectively.)value
will returnundef
if the country or field cannot be found, or if there is an error GETing the page. This isn't ideal, but I can't think of the best way around it right now. all($country_code)
-
Returns a hashref of field-value pairs for
$country_code
or an empty hashref if$country_code
isn't available from the Factbook.
CACHING
In order to make some small improvement in efficiency, WWW::CIA::Source::Web keeps a copy of the data for the last country downloaded in memory.
TO DO
- File system based caching of pages.
- User-definable stack of cached countries, rather than just one.
- Caching of last-modified headers; conditional GET.
AUTHOR
Ian Malpass (ian@indecorous.com)
COPYRIGHT
Copyright 2003, Ian Malpass
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The CIA World Factbook's copyright information page (http://www.cia.gov/cia/publications/factbook/docs/contributor_copyright.html) states:
The Factbook is in the public domain. Accordingly, it may be copied
freely without permission of the Central Intelligence Agency (CIA).
SEE ALSO
WWW::CIA, WWW::CIA::Parser, WWW::CIA::Source::DBM