I wrote this script, and it works: it clean all the files in a 157Mb directory in 6 minutes.
But I recently used it in a directory in which I stored only one 145 Mb file and it is very very very slow (I suppose because it isn't optimized: it uses memory not very well).
Someone may help me to make this script faster?
thank you, all'adr
~~~~~~~~~~~~~~~~~~~THE SCRIPT~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl -w
use strict; my $testo; my $var = 1;
@ARGV = </Users/pes/Desktop/Testo140M/*.txt>;
while(<>){
tr/\015\012/\n/s;
tr/"*^_\-+' //s;
$_ = '' if /^(?:Newsgroups: it.|Subject: |Date: |Message-ID: |References: |
From: |Message-ID: |References: )/;
s/(\w\')/$1 /g;
$testo .=$_;
if ( eof ) {
# I don't understand why the three next steps does not work before the EOF
$testo =~ s!(?:http://)?\w{3,}(?:\.(?:\w-?)+)+\.\w{2,3}\S*! URL!g;
$testo =~ tr/\n\r\f\t /\n\r\f\t /s;
$testo =~ s/ \n//g;
close $ARGV;
open ATTUALE, ">$ARGV" or die "Non posso aprire $ARGV perche' $!\n";
print ATTUALE $testo;
close ATTUALE;
print "$var - I cleaned $ARGV\n";
$testo = "";
$var++;
}}
print "DONE.\n";
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]