Skip to content

Commit c81aa5e

Browse files
committed
perltidy
1 parent 79b236a commit c81aa5e

File tree

2 files changed

+65
-35
lines changed

2 files changed

+65
-35
lines changed

.perltidyrc

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Perl Best Practices (plus errata) .perltidyrc file
2+
3+
-l=98 # Max line width is 98 cols
4+
-i=4 # Indent level is 4 cols
5+
-ci=4 # Continuation indent is 4 cols
6+
#-st # Output to STDOUT
7+
-se # Errors to STDERR
8+
-vt=2 # Maximal vertical tightness
9+
-cti=0 # No extra indentation for closing brackets
10+
-pt=1 # Medium parenthesis tightness
11+
-bt=1 # Medium brace tightness
12+
-sbt=1 # Medium square bracket tightness
13+
-bbt=1 # Medium block brace tightness
14+
-nsfs # No space before semicolons
15+
-nolq # Don't outdent long quoted strings
16+
-wbb="% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
17+
# Break before all operators
18+
19+
# extras/overrides/deviations from PBP
20+
21+
--maximum-line-length=100 # be slightly more generous
22+
--warning-output # Show warnings
23+
--maximum-consecutive-blank-lines=2 # default is 1
24+
--nohanging-side-comments # troublesome for commented out code
25+
26+
-isbc # block comments may only be indented if they have some space characters before the #
27+
-ci=2 # Continuation indent is 2 cols
28+
29+
# we use version control, so just rewrite the file
30+
-b
31+
32+
# for the up-tight folk :)
33+
-pt=2 # High parenthesis tightness
34+
-bt=2 # High brace tightness
35+
-sbt=2 # High square bracket tightness
36+

pgeodns

+29-35
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,24 @@ use Getopt::Long;
1212
use Socket;
1313

1414
my %opts = (verbose => 0);
15-
GetOptions (\%opts,
16-
'interface=s@',
17-
'user=s',
18-
'verbose!',
19-
'config=s',
20-
'configtest!',
21-
'development!',
22-
'port=i',
23-
) or die "invalid options";
15+
GetOptions(\%opts, 'interface=s@', 'user=s', 'verbose!', 'config=s', 'configtest!', 'development!',
16+
'port=i',)
17+
or die "invalid options";
2418

2519

2620
my $config_file = $opts{config} || 'pgeodns.conf';
27-
my $port = $opts{port} || 53;
21+
my $port = $opts{port} || 53;
2822

29-
exit !GeoDNS::load_config({},$config_file)
23+
exit !GeoDNS::load_config({}, $config_file)
3024
if $opts{configtest};
3125

3226
die "--interface [ip|hostname] required\n" unless $opts{interface};
33-
die "--user [user|uid] required\n" if $> ==0 and !$opts{user};
27+
die "--user [user|uid] required\n" if $> == 0 and !$opts{user};
3428

35-
$opts{interface} = [ $opts{interface} ] unless ref $opts{interface};
36-
$opts{interface} = [ map { split /\s*,\s*/ } @{$opts{interface}} ];
29+
$opts{interface} = [$opts{interface}] unless ref $opts{interface};
30+
$opts{interface} = [map { split /\s*,\s*/ } @{$opts{interface}}];
3731

38-
for my $i ( 0 .. scalar @{$opts{interface}} - 1) {
32+
for my $i (0 .. scalar @{$opts{interface}} - 1) {
3933
my $localaddr = $opts{interface}->[$i];
4034
if ($localaddr =~ /[^\d\.]/) {
4135
my $addr = inet_ntoa((gethostbyname($localaddr))[4]);
@@ -44,47 +38,47 @@ for my $i ( 0 .. scalar @{$opts{interface}} - 1) {
4438
}
4539
}
4640

47-
my $g = GeoDNS->new(server_id => $opts{interface}->[0],
48-
debug => 1,
49-
config_file => $opts{config},
50-
development => ($opts{development} ? 1 : 0),
51-
);
41+
my $g = GeoDNS->new(
42+
server_id => $opts{interface}->[0],
43+
debug => 1,
44+
config_file => $opts{config},
45+
development => ($opts{development} ? 1 : 0),
46+
);
5247

5348

5449
printf "\nStarting GeoDNS %s\n", $g->version_full;
5550

56-
my $ns = Net::DNS::Nameserver->new
57-
(
58-
LocalPort => $port,
59-
LocalAddr => $opts{interface},
60-
ReplyHandler => sub {
61-
my @reply = $g->reply_handler(@_);
62-
#warn Data::Dumper->Dump([\@reply], [qw(reply)]);
63-
@reply
64-
},
65-
Verbose => $opts{verbose},
66-
);
51+
my $ns = Net::DNS::Nameserver->new(
52+
LocalPort => $port,
53+
LocalAddr => $opts{interface},
54+
ReplyHandler => sub {
55+
my @reply = $g->reply_handler(@_);
56+
57+
#warn Data::Dumper->Dump([\@reply], [qw(reply)]);
58+
@reply;
59+
},
60+
Verbose => $opts{verbose},
61+
);
6762

6863
# print error?
6964
die "couldn't create nameserver object\n" unless $ns;
7065

7166
if (my $uid = $opts{user}) {
7267
$uid = getpwnam($uid) or die "could not lookup uid"
73-
if $uid =~ m/\D/;
68+
if $uid =~ m/\D/;
7469
setuid($uid) or die "could not setuid: $!";
7570
}
7671

7772
$g->load_config($config_file);
7873

7974
if ($ns) {
80-
$ns->main_loop;
75+
$ns->main_loop;
8176
}
8277
else {
83-
die "couldn't create nameserver object\n";
78+
die "couldn't create nameserver object\n";
8479
}
8580

8681

87-
8882
__END__
8983
9084
=pod

0 commit comments

Comments
 (0)