Created
April 26, 2013 20:44
-
-
Save rothwerx/5470311 to your computer and use it in GitHub Desktop.
Perl: MongoDB update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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