use WWW::Mechanize::Firefox; use File::Copy; # @list contains the list of links to pdf files foreach $x (@list) { my $mech = WWW::Mechanize::Firefox->new(autoclose => 1); #This downloads the file using firefox in desired folder $mech->get($x); opendir(DIR, "output/download"); @FILES= readdir(DIR); my $old = "output/download/$FILES[2]"; move ($old, $new); # $new is the URL of the new filename }