LibDirs::Perl probe for discovering perl local::lib like directories
[scpubgit/System-Introspector.git] / lib / System / Introspector / ResolvConf.pm
CommitLineData
9cebf8c1 1package System::Introspector::ResolvConf;
2use Moo;
3
4sub 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
17sub _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
241;