Hello, I'm quite new to programming in Perl and need help.
I have script which downloads data from web server through function from external module. In case of errors (like 500 read timeout) function generates warning. Is it possible to catch this warning in my main script?
I've tried to use eval{} on function call but it didn't seem to work.
Sorry for not specyfing.
I'm using BioMart Perl API to download data from EnsEMBL BioMart mirror.
And code for function which downloads data by default isn't avaible for user.
Piece of code which generetes warning looks like that:
my $ua = LWP::UserAgent->new;
$ua->timeout(20); # default is 180 seconds
$ua->proxy( ['http', 'https'], $self->proxy ) if defined $self->pr
+oxy;
my $response = $ua->request($request);
my @results;
if ($response->is_success) {
my @arr=split(/\n/,$response->content); # much neater to use 'cont
+ent' instead of 'as_string', we don't need to explicitly ignore heade
+r part of the http response any more.
foreach my $el(@arr){
$logger->warn("RESPONSE: $el");
push (@results,$el);
}
} else {
warn ("\n\nProblems with the web server: ".
$response->status_line."\n\n");
}
And I'm intrested "catching" warning from last warn().But I have to do it in my main script.