Hi there, I'm relatively new to the world of coding, and I'm starting with Perl. I have this situation; I have a directory full of files with a extension .pdbqt, about 9000 files, and I want to open specific ones following a list, about 300, open each file from directory only if it is in the list and extract from them specific information. Now I'd figured out the code for extracting the info once the file is opened but can't figure out the code for matching each name from my list with specific files in my directory. So please help me.
Here's what I have done so far with my little knowledge:
#!/usr/bin/perl -w
use strict;
use warnings;
my $file = $ARGV[0];
open (FILE, $file);
my @array = <FILE>;
close(FILE);
chomp(@array);
opendir(DIR, "path/to/folder/with/my/files");
my @files = readdir(DIR);
chomp(@files);
foreach my $i (@array)
{
if(grep @array[$i], @files)
{
my $match = (grep @array[$i], @files);
Here's my code for when I finally manage to match the element in the list with the files.
open(FILE, $i);
my @files=<FILE>;
chomp @files;
for $j (@files){
my $id = $i;
$id =~ s/out_//g;
$id =~ s/.pdbqt//g;
if($j =~ "REMARK VINA RESULT:"){
my $str = substr($j,25,5);
print "$id\t$str\n";";
}
}
Thank you so much for help