#!/usr/bin/perl -w
use MongoDB;
use strict;
my $filename = "gc_monitor.pdf";
my $fileoutname = "gc_monitor1.pdf";
my ($buf,$out);
open(DATA, $filename) or die "can't open $filename: $!";
open(DATAOUT, ">$fileoutname") or die "can't open $fileoutname: $!";
binmode(DATA);
binmode(DATAOUT);
while(!eof(DATA))
{
read(DATA, $buf, 8192);
$out.=$buf;
}
my $connection = MongoDB::Connection->new(host => 'localhost', port => 27017) or die "no server?";
my $database = $connection->test;
my $collection = $database->doc;
my $id = $collection->insert({ "link" => $ARGV[0],"file"=>$out});
my $data = $collection->find_one({"link"=>$ARGV[0]});
print DATAOUT $data->{"file"} or die "write error $!";
close(DATA);
close(DATAOUT);
阅读(1156) | 评论(0) | 转发(0) |