in reply to Sending Multi file types as e-mail attachments
Let Perl do the bookkeeping:
you can populate your arrays with push, no need for counting:push @attach_list, 'Bach.jpg'; push @attach_list, 'workshop notes.pdf', 'Booking form.pdf'; push @attach_list, qw(testaaa.xls testx.xlsx wordtest.docx); # qw() on +ly if the file names don't have spaces in them
(you'll see the advantage when you shuffle the attachments, or remove one in the middle...)
Likewise, there is no need for loop counters, if you use a "foreach" loop:for $to_em (@to_email_list) { ... $smtp->to($to_em); ... }
|
|---|