#!/usr/bin/perl -w use strict; use warnings; my $file = $ARGV[0]; open (FILE, $file); my @array = ; 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); #### open(FILE, $i); my @files=; 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";"; } }