I have a Perl script that need to do the following-
now print that string into a file
What I did for grabbing line 2-n is something like the following:
The important thing is that I don't want to alter the original file, but it seems like the splicing is not very efficient. Processing about 20files totalling 7MB takes 19 minutes!
Any more efficient methods of doing what I need to do?
It would be nice if I could for instance transfer $aFile[2-N] to String without using the $forEach, etc etc.?? Possilbe or not?
Code:
For all files in a known directory
Do some validation
If Validation succeeds Then
Concatenate the content of line 2-last line from
this file and all other file into a String
end if
while
end for all files
What I did for grabbing line 2-n is something like the following:
Code:
$theFiles= ""; #the string variable storing the
#concatenated files
forAllFiles
{
open(ONEOFTHEFILE,$fileName);
#If vadliation succeeds
{
@aFile = ONEOFTHEFILE;
splice @aFile,0,1;
foreach $eachLine(@aFile)
{
$theFiles .= $eachLine ."\n";
}
}
}
#open another file and print $theFiles to a new file.
Any more efficient methods of doing what I need to do?
It would be nice if I could for instance transfer $aFile[2-N] to String without using the $forEach, etc etc.?? Possilbe or not?