Hi,
I'm a beginner in perl and I made some code to clean log files. But the speed isn't fast enough.
So I was wondering if a more advanced user could change it a little.
Thx in advance
#!/usr/bin/perl
use warnings;
use strict;
use Term::ReadKey;
print "[-] Enter the filename: ";
chomp($file = <STDIN>);
open(LIST,$file);
@file1 = <LIST>;
close(LIST);
if (-e "cleaned.txt") {
print "[-] Can cleaned.txt be deleted? ";
$answer = <stdin>;
if ($answer =~ /yes/i) {
unlink "cleaned.txt";
}
else {
&exit
}
}
print "[-] Cleaning...\n";
foreach $data (@file1) {
($w1) = split(/:/,$data);
open(OUTPUT,">>cleaned.txt");
print OUTPUT $w1."\n" unless ($data =~ /-/);
close(OUTPUT);
}
&exit;
sub exit() {
ReadMode 2;
print "\n[-] Press ENTER to exit...";
<STDIN>;
exit;
}
edit: Sorry people. I just saw that I posted this in the wrong section. Can a mod please move this.