#!/usr/bin/perl -w

#################################################################################
# Copyright (C) 2002 Alceu Rodrigues de Freitas Junior 
#(glasswalk3r@yahoo.com.br)
# 
# based on NAI VirusScan DAT file auto updater by Bas Rijniersce (bas@brijn.nu)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    These programs are distributed in the hope that they will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with these programs; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
################################################################################

#definindo o mes

$data = localtime(time);
@data = split(/ /,$data);
$mes_atual = $data[1];

# obtendo lista de arquivos
@lista = glob("*.log");

foreach (@lista) {

	@dados_arquivo = stat($_);
	$lista = localtime($dados_arquivo[9]);
	@ctime = split(/ /,$lista);
	$mes_arquivo = $ctime[1];
	unless ($mes_arquivo eq $mes_atual) {
		print "O arquivo $_ será apagado\n";
		unlink $_ || die "Nao consigo apagar o arquivo: $!";
	}
}
