On Sun, Jul 13, 2003 at 03:16:20AM -0500, Andrew Gaffney wrote:
> I'm writing a Perl program to uninstall a whole package tree, such as 
> KDE or Gnome. Here's my code so far:
> 
> 
> #! /usr/bin/perl
> 
> 
> my @pkgs, $line;
> 
> 
> open QUERY, "emerge --nospinner -ep gnome |";
> foreach $line (<QUERY>) {
>   $line =~ s/\[.+\] (.+)  /$1/;
>   chomp $line;
>   print "${line}\n";
> #  $line =~ /(.+)\/(.+)-(\d.+)/;
>   push @pkgs, $line;
> }
> close QUERY;
> 
> foreach $line (@pkgs) {
>   print "This is a package: $line\n";
> }
> 
> When I try to access @pkgs after this, there is no data in it. It prints 
> 'This is a package: ' once and exits with no error. I know its getting 
> the data correctly, because it prints a list of all the packages on the 
> screen. What am I doing wrong?
> 

Try changing the QUERY loop as follows:

-       foreach $line (<QUERY>) {
+       while( $line = <QUERY> ) {

- PK

> -- 
> Andrew Gaffney
> 
> 
> --
> [EMAIL PROTECTED] mailing list


--
[EMAIL PROTECTED] mailing list

Reply via email to