Dear Monks,

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. Can someone have a look if they see this too and this isn't an error on my part?

Case:

Step 1: Locate on your system a directory that contains no files, but can contain subdirectories. Example "/home/my_user/foo", containing "/home/my_user/foo/bar" and /home/my_user/foo/bar2".

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 would appreciate that someone can confirm this before I report this as a bug to the maintainer of the package.

I tried the same code on a different system with File-Util-4.132140 and there it worked as expected

Kind regards

Martell

Update: All, thanks for the quick reactions and the verifying. I posted this as a bug report on cpan:
https://rt.cpan.org/Ticket/Display.html?id=115511

Update: I can confirm that the bug is resolved in version 4.161950. Thanks Tommy for your work.


In reply to Bug in latest File::Util? by martell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.