Skip to content

Instantly share code, notes, and snippets.

@peterzawistowicz
Created September 24, 2015 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterzawistowicz/b9eb97582ae2a2fe6d86 to your computer and use it in GitHub Desktop.
Save peterzawistowicz/b9eb97582ae2a2fe6d86 to your computer and use it in GitHub Desktop.
my $client = MongoDB->connect();
my $coll = $client->ns("test.foo");
# assume first operation fails due to network error
eval {
$coll->insert( $doc );
};
warn $@ if $@;
# next operation automatically reconnects to MongoDB
eval {
$coll->insert( $doc );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment