I have a script that looks at the files in a directory and displays them in a web page with check boxes next to each one. When you check off the files that you want, it emails them to you. The script works except when there are commas in the filename. Each filename is passed into an array, and then a foreach loop emails each one out using the Mail::Sender module. Here's a sample of the script...
Thanks,
Chris
Code:
use CGI qw(:standard);
use Mail::Sender;
@emails = (); # the files that the user wants emailed to them
@list = param(); # holds the parameters passed to the script
$date = param('date'); # either the current month (SomeFolder) or last month (SomeFolder2)
$emailto = param('emailto'); # email to this address
$counter = 0; # temporary counter
$email = 'helpdesk@foo.us';
foreach $selection (@list) {
if ($selection != /\d+/) {
$file = param($selection);
push @emails, $file;
}
}
print header('Email Files');
print start_html;
if ($date eq 'current') { chdir 'E:\SomeFolder'; } else { chdir 'E:\SomeFolder2'; }
foreach (@emails) {
if ($emailto eq undef) {
if ($_ =~ /.+@.+\..+_(.+@.+\..+?)_.+_/) {
$emailto = $1;
}
}
$sender = new Mail::Sender
{smtp => '192.0.1.2', from => "Helpdesk@foo.us"};
$sender->MailFile({to => "$emailto",
subject => 'Files',
msg => "These are the files you requested.",
file => "$_"});
print "<p>$_ was released to $emailto</p>";
}
print end_html;
Thanks,
Chris