if (defined($wildcard) && ($name =~ /$wildcard/)) { $ftp->get("$remotedir/$name","$localdir/$tmp") or $err=1; if ($err) { print (LOGS "Can't collect file $wildcard from dir $remotedir\n"); $ftp->quit; last; } else { rename ("$localdir/$tmp","$localdir/$fname"); } }