Hello all,
Questions: How can I tell if a file is compressed (gzip or compress)? Can I use seek/tell on a pipe or fifo? If not, are there work-arounds? Background: I currently have a script that opens a file, seeks to a position, reads some data, and quits. I would like to expand the functionality of this script to do the same thing if the file is compressed either with gzip or compress. Ideally, I'm looking for a solution that is OS-independent. But if there is a Linux/Unix-only solution, that's ok. Any pointers in the right direction appreciated. Regards, - Robert -- original script -- works just fine. #!/usr/bin/perl -w use strict; my $file="foo"; open(FH, "< $file") or die "cannot open file: $!\n"; seek(FH,10,0); my $line=<FH>; print $line; my $foo=tell(FH); print "$foo\n"; close(FH); --- expanded to handle compressed files -- doesn't work #!/usr/bin/perl -w use strict; my $file="foo.gz"; open(FH, "zcat $file | ") or # this if block ... open(FH, "< $file") or # does not work if the file ... die "cannot open file: $!\n"; # is not compressed. seek(FH,10,0); # does not work if FH is pipe my $line=<FH>; print $line; my $foo=tell(FH); print "$foo\n"; close(FH); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]