@clusters =(0..37); opendir (DIR, ".") or die "$!"; @files = grep {/cluster/} readdir DIR;print @files; for $clusters ( @clusters) { for $files (@files) { if ($files =~ /$clusters\_g/) { $file = $files; print "$clusters $file\n"; } } }