From: Robert 'phaylon' Sedlacek Date: Tue, 1 May 2012 20:17:51 +0000 (+0000) Subject: factored out pipe handling X-Git-Tag: v0.001_001~139 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3d4ae7f91549eac2b40d284748032f0ec9be6c5d;p=scpubgit%2FSystem-Introspector.git factored out pipe handling --- diff --git a/lib/System/Introspector/Packages/Apt.pm b/lib/System/Introspector/Packages/Apt.pm index f95e704..0e222a9 100644 --- a/lib/System/Introspector/Packages/Apt.pm +++ b/lib/System/Introspector/Packages/Apt.pm @@ -8,11 +8,17 @@ sub gather { }; } -sub _gather_installed { +sub _open_dpkg_query_pipe { my ($self) = @_; - my $command = "dpkg-query --show"; + my $command = 'dpkg-query --show'; open my $pipe, '-|', $command or die "Unable to open pipe to '$command': $!\n"; + return $pipe; +} + +sub _gather_installed { + my ($self) = @_; + my $pipe = $self->_open_dpkg_query_pipe; my %package; while (defined( my $line = <$pipe> )) { chomp $line;