Solved

How to zip files from perl.?

Posted on 2001-07-10
3
4,829 Views
Last Modified: 2012-06-27
I am using Perl 5.003_7 and windowNT. I want to zip all .dat file from a folder. How do I zip that files. help me.
0
Comment
Question by:arogyarajxavier
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 50 total points
ID: 6271856
You will need to dowwnload the Zlib module and install it first: http://search.cpan.org/search?dist=Compress-Zlib

use Compress::Zlib ;

chdir("/your/folder");

while <*.dat> {
  open(IN_FH, "<$_");
  $gz = gzopen($compressed_filename, "wb"); # write binary
  while (<IN_FH>) {
    $gz->gzwrite($_);
  }
  $status = $gz->gzclose() ;
  close(IN_FH);
}

0
 

Expert Comment

by:proftpd
ID: 6272321
You may also use the Archive::Zip module available from CPAN to do the same task.

Ashish
0
 

Author Comment

by:arogyarajxavier
ID: 6339603
Thanks teraplane
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading fields from the text file. 4 104
Perl strange behaviour 5 74
How to strip .csv from file name 9 84
Perl Untar File 1 68
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question