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=F3 web subministrada
my $llistotal=3Dshift(@_);
$finalitzat=3D0;
$intents=3D0;
while ($finalitzat=3D=3D0)
{
my $ua =3D LWP::UserAgent->new;
my $req =3D HTTP::Request->new(GET =3D> $llistotal);
my $res =3D $ua->request($req);
if ($res->is_success)
{
$contingut =3D $res->content;=20
$contingut =3D~ s/\015?\012/\n/g; ##per als salts de HTML
$contingut =3D~ s/\015\012?/\n/g; ## per a DOS =20
$finalitzat=3D1;
} else=20
{
$intents++;
if ($intents % 5)
{
$texterror=3D"Error No s ha obtingut la llista satisfactoriament =
".$res->status_line;
Mailtool::errors::visualitza($texterror);
}
}
=20
}
=20
return($contingut);
}
|