Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Perl: MongoDB update
sub update_mongodb {
if (!Opts::option_is_set('noupdate')) {
my $client = MongoDB::MongoClient->new(host => $mongohost, port => $mongoport);
my $database = $client->get_database( $mongodatabase );
my $db = $database->get_collection( $mongocollection );
my $mongohash = \%hosthash;
my $mongoresult = $db->update({ "hostname" => $hosthash{'hostname'} }, $mongohash, { "upsert" => 1} );
print $mongoresult;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.