Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2025-12-16 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (95 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.