John Fisher wrote:
> 
> I have successfully used zgrep in a script and loved every minute of
> it (still wet behind the ears).
>      sub pulldata
>      {
>         my $data = `zgrep $key $whichfile`;
>         print $data;
>       }
> 
> That command ran thru the whole zip file and dumped all the data, which
> for that app was just one record.
> 
> Now I need to read one record at a time from a zip file.
> 
> while ( $one_record = `unzip -p zipfile.zip`);
>   {
>       do stuff with that one_record
>    }
> 
> I am sure $one_record will have the entire file and it is huge so my
> server will run out of memory. The reason why I want to do this this
> way is due to disk space shortage, so unzipping beforehand it not really
> an option. Help !

You can use a piped open to accomplice this:

open PIPE, 'unzip -p zipfile.zip |' or die "Cannot open pipe from unzip: $!";
while ( <PIPE> ) {
    #   do stuff with that one_record
    }
close PIPE or die "Cannot close pipe from unzip: $!";


Or you could use the Archive::Zip module:

http://search.cpan.org/~nedkonz/Archive-Zip-1.06/



John
-- 
use Perl;
program
fulfillment

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

Reply via email to