in reply to Re: Re: Categorize files in directory
in thread Categorize files in directory
Once you've opened the directory and gotten a list of files, you could use this snippet to proceed.
FILE_LIST: foreach my $filename ( @files ) { open FILE, "<", $filename or die "Can't open $filename. $!\n"; my $headers = 0; while ( my $line = <FILE> ) { $headers++ if $line =~ /\bFULL\b/; if ( $headers > 1 ) { # do whatever it is you intend to do with # multi-header'ed files. next FILE_LIST; } } # Do whatever it is you intended to do with # single-header files. } continue { close FILE; } # Now you're done.
As you can see, Regular Expressions! are only a very small part of making this thing work for you.
Dave
|
|---|