in reply to how to capture status codes of mongodb in perl

Look at the docs, they are quite detailed. In particular, the docs for the MongoDB::Database object show that there is a last_error method, and you can probably do this:

my $err = $database->last_error();

to get what you want.

- Luke

Replies are listed 'Best First'.
Re^2: how to capture status codes of mongodb in perl
by praveenchappa (Acolyte) on Nov 05, 2014 at 12:29 UTC

    i have tried that,but a hash code is prinnted while trying to print that

    my $err = $database->last_error(); print $err; #prints: HASH(0x2ad39fc)

    how could i validate that

      You can dereference the reference
      print %$err;

      or, better, use Data::Dumper:

      use Data::Dumper; print Dumper $err;
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      What have you tried? Have you tried looking at the documentation, and following the link I posted? If you tried, then try reading this particular fragment again:

      last_error returns a hash with fields that vary, depending on what the previous operation was and if it succeeded or failed. If the last operation (before the last_error call) failed, either:
      err will be set or
      errmsg will be set and ok will be 0.

      If err is null and ok is 1, the previous operation succeeded.

      - Luke