On Thu, Jul 26, 2001 at 04:18:58PM -0500, Frank Newland wrote:
> Q:
> 1. Isn't CONTENTS a file handle to the uncompressed file?

No, it's a filehandle to the output of the compress command.


> 2. Why doesn't perl execute my while statement?

It does, but there's nothing to read, see below.


> 3. What should I do to print the contents of an archived file?

Probably use one of the Compress::* modules on CPAN.


> #!/usr/bin/perl

You forgot -w or use warnings.


> use strict ;
> open (CONTENTS, "compress -d  archive.Z  | " ) or die "In the
> rain....alone";

This is likely your problem.  If your compress is anything like mine, -d
compresses the file inline; it transforms a compressed 'archive.Z' into an
uncompressed 'archive'.  You need to use the -c option so compress writes
the uncompressed file to stdout.

You have some odd error messages here.  If you like poetic messages you
should take a look at Damian Conway's Coy.pm, it makes haiku (well, sorta)
out of error messages.  I'm assuming that these error messages aren't
actually being used for production code.


> while (<CONTENTS>) {
> chomp ;
> print ;

This is slightly wrong, unless you want absolutely no newlines in your
output.  The chomp removes the trailing newline, but the print never adds
one back.  You probably want:

    print while <CONTENTS>;


> }
> close (CONTENTS) or die "like Arch Stanton..."


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to