my $client = MongoDB::MongoClient->new(host => 'localhost', port => 27017);
connects to the MongoDB server running on the same machine at the default port.

The next call:
my $db = $client->get_database( 'example_' . $$ . '_' . time );
returns a database. In order to reduce the chances that we access an already
existing database we create the name of the database on the fly using the
current process id $$ and the current time in seconds.

Once we have the database object in $db we fetch the collection
which is similar to tables in relational databases, with the big difference that
we don't need to execute special commands to create it or to set up a schema:
my $people_coll = $db->get_collection('people');

The next two calls insert data structures (hash references) in the collection.
In the terminology of MongoDB they are called documents:

In addition to the data we inserted, each document also contains another
field called _id that is the unique id of this document, called
the ObjectIDd.
(but read the
specification
for more, well, specific details.)

The last statement in this example is $db->drop;. As the name
might let you guess, it will drop the database so we won't have lots
of example databases hanging around.

Manually dropping a database

If for some reason the database is not dropped at the end of the script (e.g. if
there was an exception in the code we can manually drop the database using
the mongo command line client:

update gets two hash references. The first one
{ name => 'Second'} is the selector (what would be a WHERE-clause in SQL).
It means, update the document where the "name" field equals to 'Second'.

The second hash reference does the actual update. '$set' is a MongoDB command
that tells the database engine to set a value. The { phone => '1-123'} part
tells to set the phone field to be '1-123'. Regardless if it existed or not before.