##
$ cat foo.pl
#!/usr/bin/perl
use strict;
use warnings;
my $dir = '.';
my $cat = '/bin/cat';
opendir DIR, $dir or die "Cannot open directory $dir:$!\n";
my @pdb_files = grep { -f $_ && $_ =~ /\.pdb$/ } readdir DIR;
closedir DIR;
for my $file (@pdb_files) {
my $content = `$cat "$dir/$file"`;
chomp $content;
print "Content of $file is $content\n";
}
##
##
$ perl foo.pl
Content of 1.pdb is some text
Content of 2.pdb is some more text