#!perl # return filename $condition = "pl|bak|BAK"; opendir DIR, "."; @filelist = readdir DIR; closedir DIR; foreach $file (@filelist) { if (-d $file){ print "$file ----> Directory.\n"; } elsif ($file =~ /\.($condition)$/){ print "$file ----> This file.\n"; } else { $file = $file . "\n"; push @outlist, $file; } } open OUT, ">out.txt"; print OUT sort @outlist; close OUT; exit;