#!/usr/bin/perl use strict; use warnings; use 5.010; my $env = { }; my $load_ClamAV = sub { my ($env,$her_hin) = @_; delete $her_hin->{fehler} if defined $her_hin->{fehler}; # zurück setzen my %conf_local = ( abrufe => [ { url => 'http://database.clamav.net/daily.cvd', }, ], ); require LWP::UserAgent; require HTTP::CookieJar::LWP; my $jar = HTTP::CookieJar::LWP->new; my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36', cookie_jar => $jar, protocols_allowed => ['http','https'], timeout => 10, ); foreach my $ref (@{$conf_local{abrufe}}) { my $response = $ua->get($ref->{url}); if ($response->is_success) { say __LINE__; print $response->decoded_content; } else { say __LINE__; say $response->status_line; say $response->headers()->as_string; say $response->header('content-type'); $her_hin->{fehler} = "Abruf der URL '" .$ref->{url} ."' ist gescheitert mit HTTP Status-Code " .$response->status_line ; last; } } return if defined $her_hin->{fehler}; }; ############################################################################### my %hin_her = ( ); $load_ClamAV->($env,\%hin_her); if (defined $hin_her{fehler}) { say "FEHLER!\n$hin_her{fehler}"; }