For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > Compress and email file?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Compress and email file?
Graeme McLaren

2004-04-27, 12:07 pm

Hi, I need to compress (gzip) an html file from a cgi script before
emailing the file, any ideas how?


Cheers,

Graeme :)

________________________________________
_________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger

Sumanth Sharma

2004-04-27, 12:07 pm


"Graeme McLaren" <iamnotregistered@hotmail.com> wrote in message
news:BAY16-F62YPMMhMdouT0001df4c@hotmail.com...
> Hi, I need to compress (gzip) an html file from a cgi script before
> emailing the file, any ideas how?


use Compress::Zlib;
check at http://search.cpan.org/author/PMQS/...ib-1.33/Zlib.pm for
more info.





Sumanth Sharma

2004-04-27, 12:07 pm

Here is a sample code,
use Compress::Zlib ;
..
..
..
..

open(LOG,"<$log_file1")or print "cld not open $log_file1 for reading \n";
$HTML_LOG = gzopen("$log_file2", "wb",1) or print "cld not open
$log_file2 for writing \n";
while (<LOG> )
{
$HTML_LOG->gzwrite($_)
}
close(LOG);
$HTML_LOG->gzclose();


Kevin Old

2004-04-27, 12:56 pm

On Tue, 2004-04-27 at 10:11, Sumanth Sharma wrote:
> Here is a sample code,
> use Compress::Zlib ;
> .
> .
> .
> .
>
> open(LOG,"<$log_file1")or print "cld not open $log_file1 for reading \n";
> $HTML_LOG = gzopen("$log_file2", "wb",1) or print "cld not open
> $log_file2 for writing \n";
> while (<LOG> )
> {
> $HTML_LOG->gzwrite($_)
> }
> close(LOG);
> $HTML_LOG->gzclose();


Answering the other half of your question, to mail the file use the
MailFile function in the Mail::Sender module.

http://search.cpan.org/~jenda/Mail-...der.pm#MailFile

Hope this helps,
Kevin
--
Kevin Old <kold@kold.homelinux.com>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com