Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: zcat pipe gives "gzip: stdout: Broken pipe" error

by cavac (Prior)
on Apr 01, 2025 at 13:06 UTC ( [id://11164540]=note: print w/replies, xml ) Need Help??


in reply to zcat pipe gives "gzip: stdout: Broken pipe" error

I haven't tested it, but there is PerlIO::gzip, which could allow you to do something like this:

use PerlIO::gzip; use Carp; ... my $iolayer = ''; if($filename =~ /\.gz$/i) { $iolayer = ':gzip'; } open($ifh, '<' . $iolayer, $filename) or croak("$!"); ... # Process data while((my $line = <$ifh>)) { chomp $line; if($line =~ /bla/) { doBla($line); } else { doBlub($line); } } ... close $ifh;

No pipes, no external program to worry about, just basic IO stuff.

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11164540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2025-06-16 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.