A few weeks ago, I posted a long, confusing script and asked why I couldn't email files that have comma's in the name. Nobody answered, so I wrote a shortened version of the script that only deals with the part I have a question on. When you run this script, it will email any files in C:\somedirectory to perl@foo.org. The problem is that if a file has a comma in the filename, it doesn't get emailed. I'm not sure why...
Thanks,
Chris
Code:
#!perl
use Mail::Sender;
$dir = 'C:\\somedirectory\\';
opendir(DIR, $dir) or die "Can't open $dir: $!\n";
while (defined($file = readdir(DIR))) {
chomp;
push @list, $file;
}
foreach (@list) {
$_ = $dir . $_;
$emailto = 'perl@foo.org';
$sender = new Mail::Sender
{smtp => '192.168.1.2', from => 'PerlTest@foo.org'};
$sender->MailFile({to => "$emailto",
subject => 'Files Emailed',
msg => "Emailing \" $_ \"",
file => "$_"});
print "$_ was emailed to $emailto\n";
}
Thanks,
Chris