Thursday, 18 February 2010
In allegato le schede dell'ultima gara nazionale Jesolo 2009.
Sunday, 14 February 2010
Qui di seguito pubblico un piccolo script perl per cancellare i messaggi residenti su un server ftp più vecchi di 4 giorni, per cambiare il numero di giorni basta modificare $diff > 4 ...si lo sò potevo metterci una variabile....ma la pigrizia vince sempre
use Net::POP3;
use Date::Manip;
my $file;
my @righe;
my $nr;
my $i;
my $username;
my $password;
my @params;
my $flag;
my $domain="@mydomain.com";
# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
#Nome del file da leggere con sopra username e pass nella forma username:password
$file = 'myaccounts.txt';
# Apre il file
open(INFO, $file);
# Legge tutto in un array
@righe = ;
# Chiude il file
close(INFO);
$nr = scalar(@righe);
for ($i=0;$i<$nr;$i++){
($username,$password) = split(/:/,@righe[$i]);
# Costruttore POP3
$pop = Net::POP3->new('pop3.mydomain.com');
$pop = Net::POP3->new('pop3.mydomain.com', Timeout => 60);
#Localtime
($day, $month, $year) = (localtime)[3,4,5];
$year = $year +1900;
$month = $month +1;
$date2 = $year.'-'.$month.'-'.$day;
$username = trim($username.$domain);
$password =trim($password);
print $username."\t".$password."\n";
if ($pop->login($username, $password) > 0) {
my $msgnums = $pop->list; # hashref of msgnum => size
foreach my $msgnum (keys %$msgnums) {
my $msg = $pop->get($msgnum);
$flag=1;
my $n = scalar(@$msg);
for ($count = 0; ($count <= $n)&&($flag==1); $count++) {
if (substr(@$msg[$count],0,4) eq "Date"){
my $dt = trim(substr(@$msg[$count],5));
my @dt_a = split(/ /, $dt);
my $dt_n = scalar(@dt_a);
my $msg_year = @dt_a[3];
my $msg_month = @dt_a[2];
my $msg_day = @dt_a[1];
$date1= $msg_year.'-'.$msg_month.'-'.$msg_day;
$a=&DateCalc($date1,$date2,0);
$diff=&Delta_Format($a,0,"%dt");
if ($diff > 4 ) {
$flag=0;
print "Msg:\t".$msgnum."\t".$date1."\t".$date2."\t".$diff."\n";
$pop->delete($msgnum);
}
}
}
}
}
$pop->quit;
}
|