$ ls -al pm_1208018_test_dir*
pm_1208018_test_dir:
total 0
drwxr-xr-x 3 ken staff 102 Jan 30 07:08 .
drwxr-xr-x 20 ken staff 680 Jan 30 07:43 ..
-rw-r--r-- 1 ken staff 0 Jan 30 07:08 pm_1208018_test_file
pm_1208018_test_dir_closed:
total 0
drwxr-xr-x 2 ken staff 68 Jan 30 07:40 .
drwxr-xr-x 20 ken staff 680 Jan 30 07:43 ..
pm_1208018_test_dir_empty:
total 0
drwxr-xr-x 2 ken staff 68 Jan 30 07:29 .
drwxr-xr-x 20 ken staff 680 Jan 30 07:43 ..
####
$ alias perle
alias perle='perl -Mstrict -Mwarnings -Mautodie=:all -E'
####
$ perle '
open my $fh, "<", "pm_1208018_test_dir/pm_1208018_test_file";
opendir(my $dh, "pm_1208018_test_dir");
opendir(my $eh, "pm_1208018_test_dir_empty");
opendir(my $ch, "pm_1208018_test_dir_closed");
closedir $ch;
my $nh = "42";
my $uh;
my %h = (fh => $fh, dh => $dh, nh => $nh, eh => $eh, uh => $uh, ch => $ch);
for (keys %h) {
use warnings FATAL => "io";
eval {
my $x = telldir $h{$_}; say "$_ is a dirhandle"; 1
} or say "$_ is not a dirhandle"
}
'
fh is not a dirhandle # fh = filehandle
nh is not a dirhandle # nh = not a handle (just the number 42)
eh is a dirhandle # eh = dirhandle to "pm_1208018_test_dir_empty"
dh is a dirhandle # dh = dirhandle to "pm_1208018_test_dir"
ch is not a dirhandle # ch = closed handle
uh is not a dirhandle # uh = undefined handle (declared but uninitialised)