【发布时间】:2011-01-29 09:08:25
【问题描述】:
我想用 Template::Toolkit 递归地读出一个目录来打印 HTML 页面中的数据结构。 但我一直在思考如何以易于阅读的形式保存路径和文件。
我的想法是这样开始的
sub list_dirs{
my ($rootPath) = @_;
my (@paths);
$rootPath .= '/' if($rootPath !~ /\/$/);
for my $eachFile (glob($path.'*'))
{
if(-d $eachFile)
{
push (@paths, $eachFile);
&list_dirs($eachFile);
}
else
{
push (@files, $eachFile);
}
}
return @paths;
}
我该如何解决这个问题?
【问题讨论】:
标签: perl recursion treeview directory