in reply to foreach problem
sub check_link { [download]
You didn't specify which foreach you are having trouble with. Is it this one?
foreach $link(@links) { [download]
Also, start printing things out and using Data::Dumper.