From: Robert 'phaylon' Sedlacek Date: Thu, 3 May 2012 16:19:35 +0000 (+0000) Subject: ResolvConf probe for /etc/resolv.conf info X-Git-Tag: v0.001_001~131 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9cebf8c1625ff310012064bd1b71a7b3ef9f8e06;p=scpubgit%2FSystem-Introspector.git ResolvConf probe for /etc/resolv.conf info --- diff --git a/lib/System/Introspector/ResolvConf.pm b/lib/System/Introspector/ResolvConf.pm new file mode 100644 index 0000000..cf9513c --- /dev/null +++ b/lib/System/Introspector/ResolvConf.pm @@ -0,0 +1,24 @@ +package System::Introspector::ResolvConf; +use Moo; + +sub gather { + my ($self) = @_; + my $fh = $self->_open_resolv_conf_file; + my @resolv; + while (defined( my $line = <$fh> )) { + chomp $line; + next if $line =~ m{^\s*$} + or $line =~ m{^\s*#}; + push @resolv, [split m{\s+}, $line]; + } + return \@resolv; +} + +sub _open_resolv_conf_file { + my ($self) = @_; + open my $fh, '<', '/etc/resolv.conf' + or die "Unable to read /etc/resolv.conf: $!"; + return $fh; +} + +1;