Forum Moderators: coopster & phranque

Message Too Old, No Replies

using unique values as text file name

         

lindajames

10:23 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



i have a perl application that uses the customer id to store data of that customer in a text file. so for example customer ID "12121" will have a data file called "12121.txt"

At the moment it is running fine, but as i dont know much about perl or hosting technologies i was wondering if there would be any problems with having dozens of these .txt files in the data folder?

Also, if i get a few thousand of these files, it will be a nightmare downloading them. is there any scripting way to actual zip the content of the entire data folder on the server itself, and that way i can just download the data.tar or .zip file instead of downloading dozens of files individually?

Cheers
Linda

tombola

11:17 am on Apr 2, 2004 (gmt 0)

10+ Year Member



If the Zlib module is installed, you can compress a file with this code:

use Compress::Zlib ;

$txtfile = "/path/to/your/text/file";
$binfile = "/path/to/your/compressed/file";

open(TEXTFILE,"$txtfile") or die $!;
@content = <TEXTFILE>;
close(TEXTFILE);

$buffer = "@content";
$gz = gzopen($binfile, "wb");
$byteswritten = $gz->gzwrite($buffer);
$gz ->gzclose();