con
con

Reputation: 6093

Reading gzip line from line on a mac

I have a gargantuan .gz file that I can read on Perl/Linux via

open my $zc, 'zcat GCF_000001405.25.gz|';

but when I run this code on a Mac (Perl 5.32.1) I get an error:

zcat: can't stat: GCF_000001405.25.gz (GCF_000001405.25.gz.Z): No such file or directory

so following https://serverfault.com/questions/570024/zcat-gzcat-works-in-linux-not-on-osx-general-linux-osx-compatibility

I tried

open my $zc, 'zcat < GCF_000001405.25.gz';

but this gives the error:

readline() on closed filehandle $zc at split.by.chr.pl line 32

I am aware of Compress::Zlib but it is very slow How to read data in .gz file very fast in perl programming

How can I change the open line in my perl script so that it will work on a Mac?

Upvotes: 2

Views: 793

Answers (1)

con
con

Reputation: 6093

The attempt on the OP leaves out the | that indicates the string is a program to run and not a file name. As such, the correct answer is to use

open my $zc, 'zcat < GCF_000001405.25.gz|';

See https://alvinalexander.com/perl/edu/articles/pl010004.shtml

Upvotes: 2

Related Questions