Subject: | $f->list_dir() doesn't work when no files are present in the directory. |
Date: | Tue, 21 Jun 2016 15:07:57 +0200 |
To: | bug-File-Util [...] rt.cpan.org |
From: | Martell <martell [...] telenet.be> |
Dear Tommy,
I think I found a bug in the File::Util (File-Util-4.161200) package.
$f->list_dir() doesn't work when no files are present in the directory.
Reproduction steps:
Step 1: Locate on your system a directory that contains no files, but it
can contain subdirectories. Example "/home/my_user/foo", containing
subdirectories "/home/my_user/foo/bar" and /home/my_user/foo/bar2", but
no files.
Step 2: Try to list the directories with:
perl -e 'use strict; use File::Util;my $f = File::Util->new(); my @d =
$f->list_dir("/home/my_user/foo/"); print join " ", @d, "\n";'
This results in following error:
Can't use an undefined value as an ARRAY reference
at /usr/local/share/perl/5.14.2/File/Util.pm line 452.
Step 3: Create an file in "/home/my_user/foo/". Example "test.txt"
Step 4: Run the same perl snippet again. This results in the correct
expected result:
. .. bar bar2 test.txt
Module: File-Util-4.161200
Perl version:v5.14.2
System: Linux hostname 3.4.90 #2 SMP PREEMPT Tue Aug 5 14:11:40 CST 2014
armv7l GNU/Linux
I tried the same code on a different system with File-Util-4.132140 and
there it worked as expected. See also the discussion on perlmonks:
http://www.perlmonks.org/?node_id=1166176
Kind regards
Martell