[gentoo-user] Perl question

2003-07-13 Thread Andrew Gaffney
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?

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


Re: [gentoo-user] Perl question

2003-07-13 Thread Pat Kerwan


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



Re: [gentoo-user] Perl question

2003-07-13 Thread Andrew Gaffney
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?
Nevermind. This code is simplified from what I was doing. I forgot to 
get rid of blank lines. I was then feeding the blank lines to qpkg as an 
argument causing it to just sit there and do nothing.

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