Hello again,
In my aplication I have to acces a lot of times to a web information, but I
don't want to die my apllication if a non is_succes and I want to put a message
error and waiting the answer of the user if he wants to insist or abort. I
don't know if maybe yesterday I drunk too much but today I have no idea.
Can anybody help me ?
I include for you the code of one of them that don't go correctly for this
reason, i have to use semaphores or something like this ?
This subroutine is not inside a module that uses any window.
# -------------------------------------
sub obtenirget {
# -------------------------------------
# permet obtenir la informacio de la direcció web subministrada
my $llistotal=shift(@_);
$finalitzat=0;
$intents=0;
while ($finalitzat==0)
{
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $llistotal);
my $res = $ua->request($req);
if ($res->is_success)
{
$contingut = $res->content;
$contingut =~ s/\015?\012/\n/g; ##per als salts de HTML
$contingut =~ s/\015\012?/\n/g; ## per a DOS
$finalitzat=1;
} else
{
$intents++;
if ($intents % 5)
{
$texterror="Error No s ha obtingut la llista satisfactoriament
".$res->status_line;
Mailtool::errors::visualitza($texterror);
}
}
}
return($contingut);
}