docdurdee has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks, I'm trying to use the WebService::Plotly module. It works great on two computers (running p5.20.1 on OS X 10.10.3), but it dies without warnings on three other computers (running p5.20.1 on OS X 10.8.4) dumping: HTTP::Response=HASH(0x7f87ba65afe0) Do you have any suggestions as to how to solve this problem? Here is the code:
use Modern::Perl; use WebService::Plotly; my $plotly = WebService::Plotly->new( un => $user, key => $key); my @ss = map {[split]}( '2.1120 0.0047', '2.1160 0.0045', '2.1200 0.0058', '2.1240 0.0045', '2.1280 0.0036', '2.1320 0.0029', '2.1360 0.0024', '2.1400 0.0032', '2.1440 0.0020', '2.1480 0.0014', ); my @ds = map{$_->[0]} @ss; my @ps = map{$_->[1]} @ss; my $response = $plotly->plot( \@ds, \@ps ); print "url is: $response->{url} \n"; print "filename on our server is: $response->{filename} \n";
For the computers that it works, I can dump $response:
$VAR1 = { 'filename' => 'plot from API (7)', 'warning' => '', 'url' => 'https://plot.ly/~demianriccardi/113', 'message' => '', 'error' => '' };
Thanks! D

Replies are listed 'Best First'.
Re: WebService::Plotly dies with HTTP::Response=HASH(...)
by Corion (Patriarch) on May 29, 2015 at 06:13 UTC

    The module is documented to do that:

    All of the data calls return a response hash containing the keys url, message, warning, filename and error. Normally only url and filename will be interesting to you; however message can contain extra information and will be printed if verbose is set to 1, warning can contain warnings from the server and is always printed with warn(), while a value in the error key triggers the module to die.

    So, maybe you want to wrap the calls that can fail within eval { ... } and inspect the value you get back from the call?

    use Data::Dumper; my $response; my $ok= eval { $response= $plotly->plot( ... ); 1 }; if( ! $ok ) { warn "Plotly error:"; die Dumper $@; }; ...