- my $o = tie my @hosts, 'Tie::File', $hosts_file or _die "Cannot tie $hosts_file: $!\n";
- $o->flock(LOCK_EX);
-
- foreach my $network (keys %list) {
- my %indexes;
- for (my $i = 0; $i < @hosts; $i++) {
- if ($hosts[$i] =~ /^\#$network\#$/i) {
- $indexes{start} = $i;
- }
- elsif (exists $indexes{start} && $hosts[$i] =~ /^\#\/$network\#$/i) {
- $indexes{end} = $i;
- my $count = ($indexes{end} - $indexes{start} > 1)
- ? $indexes{end} - $indexes{start} - 1
- : 0;
- splice @hosts, $indexes{start} + 1, $count, @{$list{$network}};
- last;
+ my $o = tie my @hosts, 'Tie::File', $hosts_file or _die "Cannot tie $hosts_file: $!\n";
+ $o->flock(LOCK_EX);
+
+ foreach my $network (keys %list) {
+ my %indexes;
+ for (my $i = 0; $i < @hosts; $i++) {
+ if ($hosts[$i] =~ /^\#$network\#$/i) {
+ $indexes{start} = $i;
+ }
+ elsif (exists $indexes{start} && $hosts[$i] =~ /^\#\/$network\#$/i) {
+ $indexes{end} = $i;
+ my $count = ($indexes{end} - $indexes{start} > 1)
+ ? $indexes{end} - $indexes{start} - 1
+ : 0;
+ splice @hosts, $indexes{start} + 1, $count, @{$list{$network}};
+ last;
+ }