By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

gzip complains of broken pipe with Perl

P: 1
Hello,
I am trying to parse .gz files to get some statistics - the list of those files are in the array @ribFilesList. I have a Perl script running on Gentoo Linux.
Here is my code:

Expand|Select|Wrap|Line Numbers
  1. rib_loop: foreach my $ribFile (@ribFilesList) 
  2.   {
  3.       if (!open(RIBFILE, "gzip -dc $ribFile |")) {
  4.       &logError($progname, "Unable to open ribfile $ribFile: $!");
  5.       exit $error;
  6.       }    
  7.       while(defined(my $line = <RIBFILE>))   
  8.       {    
  9.       chomp($line);
  10.       my ($peer,$prefix) = (split(/\|/,$line,7))[3,5];  
  11.       if($prefix eq $prefix_unique_hash)
  12.       {
  13.           #The prefix exists in this rib file
  14.           $counter_file=$counter_file+1;  
  15.           close(RIBFILE);
  16.           next rib_loop;
  17.       }  
  18.       }
  19.       close(RIBFILE);
  20.  
The open doesnt give an error so the code doesnt exit, however sometimes I get the error: "gzip: stdout: Broken pipe", do you know why this happens? I try to close the RIBFILE before going to another iteration of the loop to avoid this but it still persists. Any ideas why?
Thanks!
Jan 7 '08 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
Expand|Select|Wrap|Line Numbers
  1. close(RIBFILE) or die "Can't close RIBFILE: $!";
see if that helps anything.
Jan 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.