I'm pretty new to Perl so I might be missing something obvious but; I'm debugging a bug and I've narrowed down the problem to the following piece of code.
my $fetch_urls = [];
for my $input_medium ( @{ $input_media } )
{
$input_medium->{ medium } = MediaWords::DBI::Media::Lookup::find_medium_by_url( $db, $input_medium->{ url } );
if ( $input_medium->{ medium } )
{
$input_medium->{ status } = 'existing';
}
else
{
if ( MediaWords::Util::URL::is_http_url( $input_medium->{ url } ) )
{
push( @{ $fetch_urls }, $input_medium->{ url } );
}
else
{
WARN "URL is not HTTP(s): " . $input_medium->{ url };
}
}
}
the piece of code is supposed to go through all the input_media
which are URLs and check if it exists in the system if not it tries to check if the URL is valid using the is_http_url
function (at least this is what I think it's doing). What I want to do is add a timeout after which if the URL hasn't responded, I push the message URL was unreachable
Any Ideas/suggestions will be highly appreciated.