Perl list file

Hi all

I am looking for a way to list files in a directoy using perl but then exlude some of the results

i've got this to list the files, but how can exclude some of the results

#!/usr/bin/perl
$d = "/data";
opendir(DIR, $d);
foreach my $file (readdir(DIR))
    {
    print "Version: $file\n";
    }
closedir(DIR);

Explicitly: what exact file names do you want to exclude?

Generally: you can use a regex to filter in the good ones or filter out the bad ones.
(this answer is not much help because there are no details in your question)

So the code will show me Eveything directories as well. I want to exclude the directories called ( see below) from appearing.

Music
Old
OLD
3d
.
..

You can filter by checking that the input should be file.

Cheers,
Ranga:)

Sorry i was not clear, i want it to so me the directories as well ( i,e everything in /data) but i want to exclude some of the results

Maybe something like this?

#!/usr/bin/perl
%exclude = map {$_ => 1} qw(Music Old OLD 3d);
$d = "/data";
opendir(DIR, $d);
foreach my $file (readdir(DIR)) {
  print "Version: $file\n" if not defined $exclude{$file};
}
closedir(DIR);