L
Lars Eighner
This works fine to produce a list of partial file names when
there are matching files:
(main)
if ( gen::listdbs() )
{
$content .= $main::cur->start_ul;
foreach my $item (gen::listdbs()) { $content .= $main::cur->li($item);}
$content .= $main::cur->end_ul;
}
else
{ $content .= $main::cur->p("No databases found"); }
(gen)
sub listdbs {
my @list = undef;
my $i=0;
while (<$tun::datadir/*$tun::dbsuf>)
{
$_ =~ s#$tun::datadir/(.*)$tun::dbsuf#$1#;
$list[$i] = $_;
$i++;
}
return @list;
}
Once again, it works fine when there are values, but fails when
I think @list should still be undefined. (All testing with -w
and strict - no exceptions.)
When there are no matching files, the result is a one-item
list with empty contents.
I suspect
if ( gen::listdbs() )
is getting the wrong answer, but I don't know why. I can figure
out how set some kind of flag or something, but it seems to me
there should be a neat solution.
there are matching files:
(main)
if ( gen::listdbs() )
{
$content .= $main::cur->start_ul;
foreach my $item (gen::listdbs()) { $content .= $main::cur->li($item);}
$content .= $main::cur->end_ul;
}
else
{ $content .= $main::cur->p("No databases found"); }
(gen)
sub listdbs {
my @list = undef;
my $i=0;
while (<$tun::datadir/*$tun::dbsuf>)
{
$_ =~ s#$tun::datadir/(.*)$tun::dbsuf#$1#;
$list[$i] = $_;
$i++;
}
return @list;
}
Once again, it works fine when there are values, but fails when
I think @list should still be undefined. (All testing with -w
and strict - no exceptions.)
When there are no matching files, the result is a one-item
list with empty contents.
I suspect
if ( gen::listdbs() )
is getting the wrong answer, but I don't know why. I can figure
out how set some kind of flag or something, but it seems to me
there should be a neat solution.