strict conversion

This commit is contained in:
Jamie Cameron
2014-01-07 18:49:16 -08:00
parent 82f48c4fa6
commit b9aa35e3f2
2 changed files with 18 additions and 10 deletions

View File

@ -1,19 +1,22 @@
#!/usr/local/bin/perl
# Delete several refresh rules at once
use strict;
use warnings;
our (%text, %in, %access, $squid_version, %config);
require './squid-lib.pl';
&error_setup($text{'drefresh_err'});
$access{'refresh'} || &error($text{'refresh_ecannot'});
&ReadParse();
@d = split(/\0/, $in{'d'});
my @d = split(/\0/, $in{'d'});
@d || &error($text{'drefesh_enone'});
# Do the delete
&lock_file($config{'squid_conf'});
$conf = &get_config();
@refresh = &find_config("refresh_pattern", $conf);
foreach $d (sort { $b <=> $a } @d) {
$h = $conf->[$d];
my $conf = &get_config();
my @refresh = &find_config("refresh_pattern", $conf);
foreach my $d (sort { $b <=> $a } @d) {
my $h = $conf->[$d];
splice(@refresh, &indexof($h, @refresh), 1);
}

View File

@ -1,14 +1,18 @@
#!/usr/local/bin/perl
# Save or delete a refresh pattern
use strict;
use warnings;
our (%text, %in, %access, $squid_version, %config);
require './squid-lib.pl';
$access{'refresh'} || &error($text{'refresh_ecannot'});
&ReadParse();
&lock_file($config{'squid_conf'});
$conf = &get_config();
my $conf = &get_config();
&error_setup($text{'refresh_err'});
@refresh = &find_config("refresh_pattern", $conf);
my @refresh = &find_config("refresh_pattern", $conf);
my $h;
if (defined($in{'index'})) {
$h = $conf->[$in{'index'}];
}
@ -23,12 +27,13 @@ else {
$in{'max'} =~ /^\d+$/ || &error($text{'refresh_emax'});
$in{'pc'} =~ /^\d+$/ && $in{'pc'} >= 0 && $in{'pc'} <= 100 ||
&error($text{'refresh_epc'});
my @vals;
push(@vals, "-i") if ($in{'caseless'});
push(@vals, $in{'re'}, $in{'min'}, $in{'pc'}.'%', $in{'max'});
push(@vals, split(/\0/, $in{'options'}));
$newr = { 'name' => 'refresh_pattern',
'values' => \@vals };
$idx = &indexof($h, @refresh);
my $newr = { 'name' => 'refresh_pattern',
'values' => \@vals };
my $idx = &indexof($h, @refresh);
if ($h) { splice(@refresh, &indexof($h, @refresh), 1, $newr); }
else { push(@refresh, $newr); }
}