Hello,
I have two questions. The first is pretty easy: How can I make a perl script an executable file for windows so that I wouldn't need to install perl on the computer the script is going to be run?
Second, I need to merge two files together (append). One is pretty large (36 MB) and the other relatively small (2 MB). I just need to append the contents of the second file to the first file. This is what I have so far, but it is running very slowly:
So, putting the file into the array is very fast. But appending the contents of the array to the other logfile is really, really slow. I am guessing it is because it is making a system call for each line of the file. Any suggestions to speed this up?
Thanks,
- C
I have two questions. The first is pretty easy: How can I make a perl script an executable file for windows so that I wouldn't need to install perl on the computer the script is going to be run?
Second, I need to merge two files together (append). One is pretty large (36 MB) and the other relatively small (2 MB). I just need to append the contents of the second file to the first file. This is what I have so far, but it is running very slowly:
Code:
#!C:\Perl\bin\perl.exe
#Working Directory
$workingdir = "c:\\tmp";
#Log Files
$logfile = "FileInventory.log";
$logfile2 = "FileInventory2.log";
## Open the second logfile and put into an array.
my @merge = ();
open (F3, "$workingdir\\$logfile2") or die "$!";
while(<F3>){
chomp;
push @merge, $_;
}
close(F3);
## Put each line of the array into the first logfile.
foreach (@merge) {
chomp $_;
system "echo $_ >> $workingdir\\$logfile";
};
So, putting the file into the array is very fast. But appending the contents of the array to the other logfile is really, really slow. I am guessing it is because it is making a system call for each line of the file. Any suggestions to speed this up?
Thanks,
- C