Subject: | IPC::DirQueue bug? |
Date: | Mon, 4 Sep 2006 03:30:34 -0500 |
To: | bug-IPC-DirQueue [...] rt.cpan.org |
From: | Keith Amling <amling [...] uiuc.edu> |
As of IPC::DirQueue 0.07, I find that in an empty directory:
Show quoted text
> $ perl -e 'use IPC::DirQueue; my $q = IPC::DirQueue->new({"dir" => "q"}); $q->visit_all_jobs(sub { });'
> Can't use an undefined value as an ARRAY reference at /usr/lib64/perl5/vendor_perl/5.8.8/IPC/DirQueue.pm line 1216.
The bailing line is attempting to interpret the return from
get_dir_filelist_sorted as an array ref, and it seems for an empty queue
there is no returned array ref:
Show quoted text> sub get_dir_filelist_sorted {
> my ($self, $dir) = @_;
>
> if (!opendir (DIR, $dir)) {
> return (); # no dir? nothing queued
> }
> # have to read the lot, to sort them.
> my @files = sort grep { /^\d/ } readdir(DIR);
> closedir DIR;
> return \@files;
> }
Should that "return ()" maybe be a "return []"?
Keith