Solved

How to zip files from perl.?

Posted on 2001-07-10
3
4,820 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now