TT#16370 Fix perlcritic errors

Change-Id: Ifdf0034edcfd35d3e5472b0d01e3d3c2726a8d90
changes/60/13260/2
Guillem Jover 9 years ago
parent bdde38d666
commit abc5ec2c09

@ -6,13 +6,12 @@ use DBI;
use Sys::Syslog;
openlog("acc-cleanup", "ndelay,pid", "daemon");
$SIG{__WARN__} = $SIG{__DIE__} = sub {
$SIG{__WARN__} = $SIG{__DIE__} = sub { ## no critic (Variables::RequireLocalizedPunctuationVars)
syslog('warning', "@_");
};
my $config_file = "/etc/ngcp-cleanup-tools/acc-cleanup.conf";
#$config_file = "/home/rkrenn/test/acc-cleanup.conf";
open(CONFIG, "<", $config_file) or die("Program stopping, couldn't open the configuration file '$config_file'.\n");
########################################################################
@ -22,7 +21,7 @@ sub delete_loop {
my ($table, $mtable, $col, $mstart) = @_;
my $limit = '';
$vars{batch} && $vars{batch} > 0 and $limit = " limit $vars{batch}";
$vars{batch} and $vars{batch} > 0 and $limit = " limit $vars{batch}";
my $sth = $dbh->prepare("show fields from $table");
$sth->execute;
@ -122,7 +121,7 @@ sub cleanup {
my ($table) = @_;
my $limit = '';
$vars{batch} && $vars{batch} > 0 and $limit = " limit $vars{batch}";
$vars{batch} and $vars{batch} > 0 and $limit = " limit $vars{batch}";
my $col = $vars{"time-column"};
while (1) {
@ -195,7 +194,9 @@ $cmds{cleanup} = sub {
cleanup($table);
};
while (my $line = <CONFIG>) {
open my $config_fh, '<', $config_file or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
while (my $line = <$config_fh>) {
$line =~ s/^\s*//s;
$line =~ s/\s*$//s;
@ -218,3 +219,5 @@ while (my $line = <CONFIG>) {
$sub->($rest, \@rest);
}
close $config_fh;

@ -7,31 +7,25 @@ use DBI;
use Sys::Syslog;
openlog("binglog-purge", "ndelay,pid", "daemon");
$SIG{__WARN__} = $SIG{__DIE__} = sub {
$SIG{__WARN__} = $SIG{__DIE__} = sub { ## no critic (Variables::RequireLocalizedPunctuationVars)
syslog('warning', "@_");
};
our $DBUSER;
our $DBPASS;
our $DBREMOTEUSER;
our $DBREMOTEPASS;;
my %config = map { $_ => undef } qw(dbuser dbpass dbremoteuser dbremotepass);
my $config_file = "/etc/ngcp-cleanup-tools/binlog-purge.conf";
open CONFIG, "$config_file" or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
open my $config_fh, '<', $config_file or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
no strict 'refs';
while (<CONFIG>) {
while (<$config_fh>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
$$var = $value;
$config{lc $var} = $value;
}
use strict 'refs';
close CONFIG;
close $config_fh;
my (undef, $me) = uname();
@ -45,8 +39,8 @@ elsif ($me eq "sp2") {
}
my @creds = ('dbi:mysql:', $DBUSER, $DBPASS);
my @remotecreds = ('dbi:mysql:', $DBREMOTEUSER, $DBREMOTEPASS);
my @creds = ('dbi:mysql:', $config{dbuser}, $config{dbpass});
my @remotecreds = ('dbi:mysql:', $config{dbremoteuser}, $config{dbremotepass});
my $dbh = DBI->connect(@creds) or die;

Loading…
Cancel
Save