#!/usr/bin/perl
use strict;
use warnings;
my %dir = (
dirA => '.sql',
dirB => '.pdc',
);
while (my ($dir,$ext) = each %dir) {
opendir my $dir_handle, $dir or die "failed to open directory $dir $!";
FILE:
while (my $file = grep(/$ext$/, readdir $dir_handle)) {
open my $fh, $file or die "failed to open '$file' $!";
while (my $line = <$fh>) {
if ($line =~ /".+"/) {
print "Error: found double quoted string in $file\n";
close $fh;
next FILE;
}
}
}
}
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
GetOptions( "d|directory=s" > \my $path );
-d $path or die usage();
my %dir = (
sql => '.sql',
pdc => '.pdc',
);
while (my ($dir, $ext) = each %dir) {
opendir my $dir_handle, "path/$dir"
or die "failed to open directory '$path/$dir' $!";
my @files = grep(/$ext$/, readdir $dir_handle);
closedir $dir_handle;
FILE:
foreach my $file (@files) {
$file = "$path/$dir/$file";
open my $fh, '<', $file or die "failed to open '$file' $!";
while (my $line = <$fh>) {
if ($line =~ /".+"/) {
warn "Error: found double quoted string in $file\n";
close $fh;
next FILE;
}
}
}
}
sub usage {
print "usage: $0 -d base_directory";
}
What errors/warnings are you receiving?