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


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

yes, glob also accepts Perl regular expressions:
... my $start = quotemeta "$file$yesterday"; my ($file) = $sftp->glob(qr/^$start\d{6}$/, names_only => 1); ...
But there are easier ways to do what you want. For instance, you can use a regular expression matching all the prefixes in @ai_files_day plus $yesterday plus any six digits and let mget download all the files matching:
$sftp->setcwd($ai_dir); my $starts = join('|', map quotemeta, @ai_files_day); $sftp->mget(qr/^(?:$starts)$yesterday\d{6}$/, $ai_dest_day);