#!/usr/bin/perl # 把指定目录下的所有pod文档转换为.html格式 use Data::Dumper; if (++$#ARGV < 1) { msg("usage: perl pod2html.pl DIR"); exit; } dirtree($ARGV[0]); sub dirtree { my $dorf = shift; if (-f $dorf){ if ($dorf =~/(?:\.pod$)|(?:\.POD$)/) { msg("handle File ".$dorf.".....\n"); handle_pod_file($dorf); } } if (-d $dorf){ msg("current dir ".$dorf."...\n"); opendir(DIR, $dorf); my (@filelist) = readdir(DIR); close(DIR); foreach my $file (@filelist) { if ($file eq '.' or $file eq '..') {} else { my ($fullfilename) = $dorf."/".$file; dirtree($fullfilename); } } } } sub handle_pod_file{ my $pod_file = shift; system("pod2html $pod_file>$pod_file.html"); return; } sub msg{ my $msg = shift; print $msg,"\n"; }