Skip to content

Commit

Permalink
move to LWP::Simple, correct typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
infobrightdb committed Jun 15, 2011
1 parent 92e877e commit cce8586
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions lib/ibLib.pm
Expand Up @@ -38,18 +38,16 @@
### OTHER DEALINGS IN THE SOFTWARE. ### ### OTHER DEALINGS IN THE SOFTWARE. ###
########################################################### ###########################################################




use warnings; use warnings;
use strict; use strict;


use Getopt::Long; use Getopt::Long;
use Data::Dumper; use Data::Dumper;
use WWW::Curl::Easy; use LWP::Simple


## defaults ## defaults


$| = 1; $| = 1;


my $DEBUG = 0; my $DEBUG = 0;
my $data = "./data"; my $data = "./data";
Expand Down Expand Up @@ -91,8 +89,8 @@ sub makefilename {
if ( $month < 10 ) { $month = "0" . $month } if ( $month < 10 ) { $month = "0" . $month }
if ( $day < 10 ) { $day = "0" . $day } if ( $day < 10 ) { $day = "0" . $day }
if ( $hour < 10 ) { $hour = "0" . $hour } if ( $hour < 10 ) { $hour = "0" . $hour }
if ( $min < 10 ) { $hour = "0" . $hour } if ( $min < 10 ) { $min = "0" . $min }
if ( $sec < 10 ) { $hour = "0" . $hour } if ( $sec < 10 ) { $sec = "0" . $sec }
$filename .= $year . $month . $day . "-" . $hour . $min . $sec; $filename .= $year . $month . $day . "-" . $hour . $min . $sec;
return $filename . $suffix; return $filename . $suffix;
} }
Expand All @@ -116,27 +114,9 @@ http://dammit.lt/wikistats/projectcounts-20110531-210000
=cut =cut


sub getdata { sub getdata {
## could use a better module, using module installed on current machine
my ( $url, $outfile ) = @_; my ( $url, $outfile ) = @_;
my $curl = WWW::Curl::Easy->new;

open( my $mydata, '>', "./$outfile" ); open( my $mydata, '>', "./$outfile" );
$curl->setopt( CURLOPT_URL, $url ); my $content = getstore( $url, $outfile );

$curl->setopt( CURLOPT_WRITEDATA, \$mydata );
my $retcode = $curl->perform();
if ( $retcode == 0 ) {

print Dumper($mydata) if $DEBUG > 2;
print "#file retreived\n\n";

}
else {
die "# error on curl "
. $curl->strerror($retcode) . " "
. $curl->errbuf . "\n";
}

} }


sub makeurl { sub makeurl {
Expand Down

0 comments on commit cce8586

Please sign in to comment.