! /usr/local/bin/perl -w #Skript searches for filenames in a spec. directory #referring to a text file which contains a list of Ids $dir = $ARGV[0]; #Scan a directory and write filenames into an array opendir (SOURCE, $dir)or die "Cannot open dir: $!\n"; foreach $file (readdir SOURCE) { push (@dirFile, $file); #more than 6000 filenames } closedir SOURCE; #Open a filehandle and read a list from a text file $ref = "indexDS.txt"; open(FH, $ref) or die "Cannot open file: \n$!"; @ds = ; close (FH); chomp @dirFile; chomp @ds; #Test: it works if array is defined like this: #@ds = ("I C 7702", "I C 7710", "I C 7713"); #Search for element of @ds as regex in @dirFile foreach $line (@ds) { @result = grep (/$line/, @dirFile); foreach (@result) { print "$_\n"; } }