#!/usr/bin/perl #Decompile .chm file to html format. #Author Huang Yong. #2007-9-10 #Usage:progname filename1 filename2 ... #可使用通配符 use File::Copy; use File::Basename; sub decompiler { my $chmfile = $_[0]; my $tmp = "temp"; while (-e "$tmp.chm" or -d $tmp){ my $i=1; $tmp = $tmp.$i; $i++; } die "Cannot open file $chmfile" unless (-e $chmfile); copy($chmfile,"$tmp.chm") or die "Copy failed: $!"; mkdir ("$tmp") or die "Cannot create temp!"; `hh.exe -decompile $tmp $tmp.chm`; my $tm = basename($chmfile); my $html_dir; if ($tm =~ m@(.+)\.chm@i){ $html_dir = $1; } move("$tmp",$html_dir); unlink ("$tmp.chm"); } foreach(@ARGV){ my @chmfile = glob $_; foreach $file(@chmfile){ print "正在反编译 $file,请稍候...\n"; decompiler($file); print "文件$file编译完成。\n" } } |
#!/usr/bin/perl #Decompile .chm file to html format. #Author Huang Yong. #2007-9-10 #Usage:progname filename1 filename2 ... #可使用通配符 use File::Copy; use File::Basename; sub decompiler { my $chmfile = $_[0]; my $tmp = "temp"; while (-e "$tmp.chm" or -d $tmp){ my $i=1; $tmp = $tmp.$i; $i++; } die "Cannot open file $chmfile" unless (-e $chmfile); copy($chmfile,"$tmp.chm") or die "Copy failed: $!"; mkdir ("$tmp") or die "Cannot create temp!"; `hh.exe -decompile $tmp $tmp.chm`; my $tm = basename($chmfile); my $html_dir; if ($tm =~ m@(.+)\.chm@i){ $html_dir = $1; } move("$tmp",$html_dir); unlink ("$tmp.chm"); } foreach(@ARGV){ my @chmfile; if(m@[*?[]]@){ @chmfile =glob($_); } else{ push(@chmfile,$_); } foreach $file(@chmfile){ print "正在反编译 $file,请稍候...\n"; decompiler($file); print "文件$file编译完成。\n" } } |
#!/usr/bin/perl #Decompile .chm file to html format. #Author Huang Yong. #2007-9-10 #Usage:progname filename1 filename2 ... #可使用通配符 use File::Copy; use File::Basename; sub decompiler { my $chmfile = $_[0]; my $tmp = "temp"; my $i=1; while (-e "$tmp.chm" or -d $tmp){ $tmp = $tmp.$i; $i++; } die "Cannot open file $chmfile" unless (-e $chmfile); copy($chmfile,"$tmp.chm") or die "Copy failed: $!"; mkdir ("$tmp") or die "Cannot create temp!"; `hh.exe -decompile $tmp $tmp.chm`; my $html_dir = basename($chmfile); $html_dir =~ s/\.chm$//; move("$tmp",$html_dir); unlink ("$tmp.chm"); } for(@ARGV){ my @chmfile; if(m@[*?\[\]]@){ @chmfile =glob($_); } else{ push(@chmfile,$_); } for $file(@chmfile){ print "正在反编译 $file,请稍候...\n"; decompiler($file); print "文件$file编译完成。\n" } } |
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |