my $conn = MongoDB::Connection->new( host => 'hostname', port => 27017, username=>'xxxx', password=>'xxxx', db_name => 'xxxx' ); my $database = $conn->get_database( 'xxxx' ); my $collection = $database->get_collection( 'student' ); my $data = $collection->find({"id"=>"stu_7";}); #i want to check exit or status code here !!!!!!! #...... while (my $doc = $data->next) { my @qual=@{$doc->{'qualifications'}}; print @qual; }