My PERL development was revolving up to now around web and database connectivity.
Now, I'm trying to use it in my day-to-day sysadmin task on our UNIX boxes.
Here is a very simple script which gives my some trouble for one reason or another:
open(DIR, ".") or die "Can't open the current directory: $!\n";
my @names = readdir(DIR) or die "Unable to read current dir: $!\n";
closedir(DIR);
foreach my $name (@names) {
next if ($name eq ".");
next if ($name eq "..");
if (-d $name) {
print "found a directory: $name\n";
next;
}
if ($name eq 'core') {
print "found 'core' file!\n";
}
}
The script dies at my @names = readdir(DIR) or die "Unable to read current dir: $!\n";
closedir(DIR); with a "Bad file descriptor" error message.
What does that mean?
Thanks.