Commit | Line | Data |
9cebf8c1 |
1 | package System::Introspector::ResolvConf; |
2 | use Moo; |
3 | |
4 | sub gather { |
5 | my ($self) = @_; |
6 | my $fh = $self->_open_resolv_conf_file; |
7 | my @resolv; |
8 | while (defined( my $line = <$fh> )) { |
9 | chomp $line; |
10 | next if $line =~ m{^\s*$} |
11 | or $line =~ m{^\s*#}; |
12 | push @resolv, [split m{\s+}, $line]; |
13 | } |
14 | return \@resolv; |
15 | } |
16 | |
17 | sub _open_resolv_conf_file { |
18 | my ($self) = @_; |
19 | open my $fh, '<', '/etc/resolv.conf' |
20 | or die "Unable to read /etc/resolv.conf: $!"; |
21 | return $fh; |
22 | } |
23 | |
24 | 1; |