Skip to content

Commit 6a2c459

Browse files
committed
genblock: return using wantarray
Also, I decided I like using a hash there better after all.
1 parent 8fae11a commit 6a2c459

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

genblock

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ PROCESS_LINE: while ( <<>> ) {
173173
174174
$unique_domains{$domain}++;
175175
}
176-
return \%unique_domains;
176+
wantarray
177+
? return %unique_domains
178+
: return \%unique_domains;
177179
}
178180
179181
our $opt_h;
@@ -185,23 +187,23 @@ usage if defined($opt_h);
185187
my @formats = qw(plain unbound rpz);
186188
first { $opt_t eq $_ } @formats or die "$opt_t is not a valid type.\n";
187189
188-
my $domain_appearances_hashref = &unique_domains
190+
my %domain_appearances = &unique_domains
189191
or die "Unable to extract any domains from input.\n";
190192
191193
if ( $opt_t eq 'plain' ) {
192-
print map { "$_\n" } sort keys %$domain_appearances_hashref;
194+
print map { "$_\n" } sort keys %domain_appearances;
193195
}
194196
elsif ( $opt_t eq 'unbound' ) {
195197
print map { "local-zone: \"$_\" always_refuse\n" }
196-
sort keys %$domain_appearances_hashref;
198+
sort keys %domain_appearances;
197199
}
198200
elsif ( $opt_t eq 'rpz' ) {
199-
&reduce_domains( $domain_appearances_hashref );
201+
&reduce_domains( \%domain_appearances );
200202
201203
#<<<
202204
print map {
203205
"$_ CNAME .\n"
204206
. "*.$_ CNAME .\n"
205-
} sort keys %$domain_appearances_hashref;
207+
} sort keys %domain_appearances;
206208
#>>>
207209
}

0 commit comments

Comments
 (0)