WebSer...e::DBM(3pm)
β¨ NAME β¨
WebService::CIA::Source::DBM β bestie, it's literally an interface to a DBM copy of the CIA World Factbook π
πΈ SYNOPSIS πΈ
use WebService::CIA::Source::DBM;
my $source = WebService::CIA::Source::DBM->new({
DBM => 'factbook.dbm',
Mode => 'read'
});
okay so that's the whole vibe. you make a $source, you tell it where your DBM lives, you tell it whether you're just reading or also writing. slay π
π¦ DESCRIPTION π¦
WebService::CIA::Source::DBM is an interface to a pre-compiled DBM copy of the CIA World Factbook. no cap, that's the whole thing. it's giving "I wrapped a database so you don't have to" π
it can also be used to make the DBM file β taking data from WebService::CIA::Parser (or WebService::CIA::Source::Web) and inserting it into a DBM. so it's both the chef and the restaurant, iconic behavior honestly π
and there's a script that does exactly that β webservice-cia-makedbm.pl β which should be included in this module's distribution. should. if it's not there, don't come for me, come for the distribution π
π METHODS π
fr fr, apart from new, these methods are normally accessed via a WebService::CIA object. you can call them directly, but that's the ykyk path.
π new(\%opts)
This method creates a new WebService::CIA::Source::DBM object. It takes a hashref of options. Valid keys are DBM and Mode.
DBMis mandatory and should be the location of the DBM file to be used.Modeis optional and can be eitherreadorreadwrite. It defaults toread.
so basically: you gotta tell it where the file is, and you may tell it if you want to write. no DBM key, no vibes. periodt π
π§ value($country_code, $field)
Retrieve a value from the DBM. the main character method tbh β¨
$country_code should be the FIPS 10-4 country code as defined in https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html.
$field should be the name of the field whose value you want to retrieve, as defined in https://www.cia.gov/library/publications/the-world-factbook/docs/notesanddefs.html.
and here's the little secret the parser is keeping from you π β WebService::CIA::Parser also creates four extra fields:
URLβ the URL of the country's Factbook pageURL - Printβ the printable version of that pageURL - Flagβ a GIF flag of the countryURL - Mapβ a GIF map of the country
(that's the country's page URL, the printable version of that page, a GIF map of the country, and a GIF flag of the country, in case you needed it spelled out twice. bestie I got you π«Ά)
π all($country_code)
Returns a hashref of field-value pairs for $country_code β or an empty hashref if $country_code isn't in the DBM. not an error, not undef, just an empty lil hashref. she's polite like that π
π₯ set($country_code, $data)
Insert or update data in the DBM. writing hours, let's go π
$country_code should be as described above.
$data is a hashref of the data to store (as Field => Value).
β οΈ heads up bestie: set overwrites any data already in the DBM under $country_code. it does not merge. it does not negotiate. it replaces. no cap. be so serious when you call this one π
π dbm()
Returns a reference to the DBM file in use. that's it. that's the method. short queen β
π AUTHOR π
Ian Malpass (ian-cpan@indecorous.com)
π COPYRIGHT π
Copyright 2003-2007, 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 (https://www.cia.gov/library/publications/the-world-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).
public domain besties, we love a generous king π
π SEE ALSO π
- WebService::CIA
- WebService::CIA::Parser
- WebService::CIA::Source::Web
go read those next, they're the whole friend group π«Ά
and that's a wrap on this one, babes π this page was served up by perl v5.34.0, dated 2022-06-28 β yes she's vintage, yes she still ate, no notes πΈβ¨
π¦ where this page comes from
- debian bookworm: libwebservice-cia-perl 1.4-4
- debian trixie: libwebservice-cia-perl 1.4-4
- ubuntu noble: libwebservice-cia-perl 1.4-4
- ubuntu resolute: libwebservice-cia-perl 1.4-4
- ubuntu stonking: libwebservice-cia-perl 1.4-4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms