I am trying to download some xml files from a given URL. Below is the code which I have used for the same-
use strict;
use warnings;
my $url ='https://givenurl.com/';
my $username ='scott';
my $password='tiger';
system("wget --user=$username --password=$password $url") == 0 or die "system execution failed ($?): $!";
local $/ = undef;
open(FILE, "<index.html") or die "not able to open $!";
my $index = <FILE>;
my @childs = map /<a\s+href\=\"(AAA.*\.xml)\">/g , $index;
for my $xml (@childs)
{
system("wget --user=$username --password=$password $url/$xml");
}
But when I am running this, it gets stuck in the for-loop wget command. It seems wget is not able to fetch the files properly? Any clue or suggestion?
Thank you.
Man