Hello kind Monks, I am having difficulty pulling data from inside multiple log files and sorting that data into one singular file that consists of every file.
I have created a perl script that can take all of the files in any directory and put the ones that are wanted into an array, (in this case I want all of the log files that start with 'secure'). I can get the files into the array no problem, but I do not know how to condense all of the data into a singular file afterwards.
Here is my code:
my @JanFiles; my $file; my $infile; my $JanFiles; my @files; my $dh; my @secures; my $outfile = 'secure.200601'; my $INFILE = @secures; opendir( $dh, "." ) or die "Can't open '.':$!\n"; while( $file = readdir($dh) ) { # add it to the set of files... push( @files, $file ); #print "[$file]\n"; } closedir( $dh ); # verify that @files got stuff .. print "===========================\n"; print "Verifying all file names.\n"; foreach( @files ) { print "[$_]\n"; } # Let's make a private reserve # of files that contain the word # 'secure' in file name #@secures; foreach( @files ) { if (/secure/) { if ( $_ ne "secure.200601") { push( @secures, $_ ); } } } #@secures = sort @secures; print "===========================\n"; print "Verifying only 'secure' file names.\n"; foreach( @secures ) { print "secure file = [$_]\n" } foreach( @secures ) { push (@secures, grep(/^Jan/ , @JanFiles )); } foreach( @JanFiles ) { print "JAN FILES = [$_]\n" } open (FILE, ">> $outfile") || die "Unable to open Write File! \n"; print FILE @JanFiles; close FILE; #foreach( @JanFiles ) { # print "JanFile = [$_]\n" #} exit;
Thank you in advance. I will be here for any further needed information.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |