WebSer...e::DBM(3pm)

πŸ“¦
version 1.4 Β· 2 versions
  • 1.4 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.4 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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.

  • DBM is mandatory and should be the location of the DBM file to be used.
  • Mode is optional and can be either read or readwrite. It defaults to read.

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 page
  • URL - Print β€” the printable version of that page
  • URL - Flag β€” a GIF flag of the country
  • URL - 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 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 🌸✨