in reply to Re^2: How to pass query for mongo DB through perl
in thread How to pass query for mongo DB through perl

With what part of the text do you have problems?

Next, we can translate the important parts into Perl:

$db->run_command( [ validate => "foo" ] );

As this is a project for your studies, I can only recommend talking to your mentor about advice regarding the use of MongoDB.

Replies are listed 'Best First'.
Re^4: How to pass query for mongo DB through perl
by ravi45722 (Pilgrim) on Sep 23, 2015 at 03:43 UTC

    Finally I completed like this

    #!/usr/bin/perl use warnings; use strict; use MongoDB; use Time::Local; my $date=$ARGV[0]; $date or $date=`date --date='90 day ago' +%d-%m-%Y`; chomp $date; print "Deleting before this date: ",$date,"\n"; my $db_host="***.**.**.***"; #For security reasons stared my ip my $db_name="ravi"; my $client = MongoDB::MongoClient->new(host => $db_host, port => 2 +7017); my $db = $client->get_database( $db_name ); my $data = $db->get_collection('collection')->find(); while (my $row = $data->next) { my $docDate = $row->{'Date'}; my $queryDate = "14-06-2015"; #substr("okay", 1,2) my $timestamp = ":00:00:00"; $docDate = $docDate.$timestamp; my ($mday,$mon,$year,$hour,$min,$sec) = split(/[\s.:-]+/, $docDate +); my $docDateMillis = timelocal($sec,$min,$hour,$mday,$mon-1,$year); $queryDate = $queryDate.$timestamp; ($mday,$mon,$year,$hour,$min,$sec) = split(/[\s.:-]+/, $queryDate) +; my $queryDateMillis = timelocal($sec,$min,$hour,$mday,$mon-1,$year +); if($docDateMillis < $queryDateMillis) { my $id = $row->{'_id'}; my $removed=$db->get_collection('collection')->remove({'_id' = +> $id}); print $id,":::Removed\n"; } }