1 #!/usr/bin/perl -w 2 3 use warnings; 4 use strict; 5 6 use File::Find; 7 8 open my $log, '>', 'log.txt' 9 or die "Can't open the log file!: $!"; 10 11 find(\&check_data, "./test"); 12 13 sub check_data { 14 15 my $file = $_; #for clarity 16 17 return if ! -f $file; 18 19 open my $fh, '<', $file 20 or die "Can't open file $file: $!"; 21 22 for my $line (<$fh>){ 23 if ($line =~ /^HELLO/){ 24 my @parts = split(/\//, $line); 25 for my $index (qw(1 3 4)){ 26 if (! $parts[$index] or $parts[$index] =~ /[\s+-]/){ 27 print $log "$file is missing data.\n"; 28 return 29 } 30 } 31 } 32 } 33 }