sub removedir { my $dir= shift; opendir DIR, $dir or die "opendir $dir: $!"; for (readdir DIR) { next if /^\.{1,2}$/; my $path = "$dir/$_"; #check $path is a file? if(-f $path) { print "file: $path\n"; } } }