I uncluded the line $filename = "/tmp/".$name."\n"; to make the path absolute and is not detecting that is executable.
The -x should find out if the file is executable then it will perform the action inside the the braces?
- #!/usr/bin/perl
-
-
my $dir_to_process = "/tmp";
-
opendir (DIR, $dir_to_process) || $dir or die "Cannot open $dir: $!";
-
-
while (my $name = readdir DIR) {
-
next if $name =~ /^\./;
-
-
$filename = "/tmp/".$name."\n";
-
-
if (-x $filename)
-
-
{
-
print "Do something";
-
}
-
-
}
-