http://www.perlmonks.org?node_id=1028164


in reply to Re^2: Net::SFTP::Foreign getting files
in thread Net::SFTP::Foreign getting files

Oh, I see, you are calling glob in scalar context where it returns the number of files matching. Also, you don't need mget when you have already used glob to resolve the name. get will do in that case:
($file) = $sftp->glob($file, names_only => 1); defined $file or die "file not found"; $sftp->get($file, "$ai_dest_day/$file");