Bootscat wrote at Tue, 01 Oct 2002 00:10:32 +0200: > I'm setting up a list for free and pro members. > I want the pro members to be able to mail daily. I have this part working. > > I want the free members to only be able to mail every 4 Days to the list. > > Using the localtime(time) = > (second,minute,hour,day-of-month,month,year,day-of-week,day-of-year) > > Can someone tell me how to code it to only allow it to mail > every 3 days? > > Here's the code I already have working. I'm just adding a free members to > mail every 4 Days. I have it checking the LSend file to see when mail was last sent >like this. > if($lastsend eq "$date"){ > > If work geat for everyday mailings. > > But how do I have it check the LSEND to work for every 3 or 4 days? > >> my ($sec,$min,$hour,$dom,$mon,$year,$dow,$doy) = localtime; >> if ( not $doy % 3 ) { >> sendmail(); >
I ignore your huge script, as the basic idea is very simple. You need a key-value structure of your free members (the keys should be their member_ids, names or whatever they are identified unarbitrarely, the value should be the (year,month,day)-date of the last succeeded mailing). The key value structure can be a tied hash, a database, a flat file csv file or anything else, it isn't so important. Then all you have to do is something like this PseudoCode: use POSIX qw/strftime/; use Date::Calc; # available from CPAN my $current_date = strftime "%y%m%d"; if (Delta_Days($last_send_mail_date{$user}, $current_date) >= 4) { sendmail; last_send_mail_date{$user} = $current_date; } Of course, you can also use the direct way instead of the strftime function, but I always forget the return parameters of localtime :-)) Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]