I have a variable amount of text files that need to get parsed. The files come in groups of 6. I only need to parse files 4 5 and 6. So if I had 3 groups waiting to be processed then I would have to read through and parse 4,5,6,10,11,12,16,17,18.
The file names look like this... 6.1.200_(1)_(9443).txt Date_element of group_time.txt So I would processing all of the files for 6.1. Also I couldn't figure out a way to sort them easily as you will see me in my code so any suggestions there would be helpful also. How can I setup a loop that will run the correct amount of times and only parse these files from the group. Here is my code. #!/usr/bin/perl use warnings; use strict; use DBI; opendir ( DH, "." ) or die ( "Could not open $!\n" ); my @allfiles = readdir(DH); my %sales; foreach ( @allfiles ) { next unless /^\d+\.\d+\.\d+_/; push (@{$sales{$1}}, $_) if /^(\d+\.\d+\.\d+)_/; } foreach (sort keys %sales){ my $salesjournals = scalar(@{$sales{$_}}); &processdate($sales{$_}, $salesjournals); die; } sub processdate { my ($filenames, $salesjournals) = ( shift, shift ); my (%pel, %cfb, %leimkuehler, @files); foreach ( @ { $filenames } ){ push (@files, $1 . "-$_") if /_\((\d+)\)_/; } @files = sort {$a <=> $b} @files; foreach (@files){ my $tmp = $1 if s/^(\d+)-//; if ( $tmp == ){ print "$tmp \t $_\n"; } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]