| 1 | use strict;
|
|---|
| 2 | use warnings;
|
|---|
| 3 | use LWP::UserAgent;
|
|---|
| 4 | use HTTP::Request::Common;
|
|---|
| 5 |
|
|---|
| 6 | my $FH;
|
|---|
| 7 | my $upfile = shift;
|
|---|
| 8 | open($FH, "$upfile") or die "can not open $upfile $!";
|
|---|
| 9 |
|
|---|
| 10 | my $ua = LWP::UserAgent -> new;
|
|---|
| 11 |
|
|---|
| 12 | # POST準備
|
|---|
| 13 | my $url = 'http://sw05.dbcls.jp/bigdata/sparql';
|
|---|
| 14 | #my $url = 'http://sw05.dbcls.jp/bigdata/sparql?delete';
|
|---|
| 15 | my $postdata = "";
|
|---|
| 16 |
|
|---|
| 17 | my $counter = 0;
|
|---|
| 18 | while(my $line = <$FH>){
|
|---|
| 19 | $counter++;
|
|---|
| 20 | $postdata .= $line;
|
|---|
| 21 |
|
|---|
| 22 | if($counter%10000 == 0){
|
|---|
| 23 | my $request = POST( $url );
|
|---|
| 24 | $request->content_type('text/plain');
|
|---|
| 25 | $request->content($postdata);
|
|---|
| 26 |
|
|---|
| 27 | # 送信
|
|---|
| 28 | my $res = $ua -> request( $request );
|
|---|
| 29 | print $res -> as_string;
|
|---|
| 30 | $postdata = "";
|
|---|
| 31 | $counter = 0;
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | my $request = POST( $url );
|
|---|
| 36 | $request->content_type('text/plain');
|
|---|
| 37 | $request->content($postdata);
|
|---|
| 38 |
|
|---|
| 39 | # 送信
|
|---|
| 40 | my $res = $ua -> request( $request );
|
|---|
| 41 | print $res -> as_string;
|
|---|
| 42 |
|
|---|
| 43 | close($FH);
|
|---|
| 44 |
|
|---|
| 45 | 1; |
|---|