Mike wrote:
I'm a perl newbie and need help with writing a script to do the
following:
1) Open a file that is delimited. The file is in this format:
<name>;<email address1>;<user1>;<user2>;....<userX>;
The delimiters can be changed. This is a manually created file.
Email and user may be more than one item.
Use the split function to separate delimited fields:
my @fields = split /;/, $data;
perldoc -f split
Or use one of the CSV modules.
2) Send an email to <email address> using the file from #1. The
email should be like
To <name>
Please verify that the following users are still under your
supervision by <date>:
<user1>
<user2>
<userX>
There are various modules that will send email including Net::SMTP and
Mail::Send amongst others.
3) For calculating the date, I've used the below and added 14 days
(1209600 seconds):
@Weekdays = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday');
@Months = ('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December');
@Now = localtime(time + 1209600); # adding the number of seconds in a
day (86400) and multiplying for 14 days
$Month = $Months[$Now[4]];
$Weekday = $Weekdays[$Now[6]];
$Hour = $Now[2];
if ($Hour > 12) {
$Hour = $Hour - 12;
$AMPM = "PM";
} else {
$Hour = 12 if $Hour == 0;
$AMPM ="AM";
}
$Minute = $Now[1];
$Minute = "0$Minute" if $Minute < 10;
$Year = $Now[5]+1900;
$Expire = "$Weekday, $Month $Now[3], $Year";
$ perl -MPOSIX -le' print strftime "%A, %B %d, %Y %I:%M %p", localtime '
Wednesday, June 13, 2007 11:30 AM
$ perl -MPOSIX -le' print strftime "%A, %B %d, %Y %I:%M %p", localtime time +
1_209_600 '
Wednesday, June 27, 2007 11:31 AM
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/