linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘建议留言网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > 开发语言 > perl >
栏目导栏
  php
  JSP
  ASP
  asp.net
  JAVA
  c/c++/c#
  perl
  JavaScript
  Basic
  Delphi
资料搜索
热门文章
·perl入门学习指南
·perl入门教程:Perl 的变量
·Perl文件及目录操作
·perl入门教程:正则表达式
·perl入门教程:Perl的语法与C语
·perl入门教程:Perl概述
·Perl常用系统函数
·perl中传递和存储文件句柄
·perl 学习笔记
·perl入门教程:Perl 程序的属性
·Perl命令行应用介绍
·Perl连接Oracle数据库的方法
·curl+perl的自动MAIL报警程序
·Perl的基本输入输出
·使用 perldoc 找文档
最新文章
·perl 学习笔记
·Perl 特殊变量
·perl Base64码的获取
·perl 父子进程的数据库连接继承
·工作中的实用 perl 脚本
·perl中传递和存储文件句柄
·curl+perl的自动MAIL报警程序
·Perl类包的动态调用
·使用open创建的管道进行父子进
·perl 执行一个系统命令(svn in
·windows平台下根据可执行文件名
·关联数组(hash)
·Perl语言在风险评估的系统基础
·在Perl/CGI中使用模板
·PERL CGI 常见问题
Google
 
批量反编译chm文档的perl脚本
[ 作者:weiqiboy  加入时间:2007-09-30 16:04:19  来自:Linux联盟收集整理 ]
chm文档可使用\windows\hh.exe反编译,但它一次只能反编译一个chm文档,也不支持长文件名,我写了一个脚本使之可以批量反编译chm文档,当然也可以“支持”任何合法的文件名(这里之所以把支持括起来是因为脚本里使用了小伎俩,并非真的使hh支持长文件名),使用方法:脚本名 filename1 filename2 ...(这里的filename 可以支持通配符,如*.chm.x2dLinux联盟
#!/usr/bin/perlx2dLinux联盟
x2dLinux联盟
#Decompile .chm file to html format.x2dLinux联盟
x2dLinux联盟
#Author Huang Yong.x2dLinux联盟
x2dLinux联盟
#2007-9-10x2dLinux联盟
x2dLinux联盟
#Usage:progname filename1 filename2 ...x2dLinux联盟
x2dLinux联盟
#可使用通配符x2dLinux联盟
x2dLinux联盟
x2dLinux联盟
use File::Copy;x2dLinux联盟
use File::Basename;x2dLinux联盟
x2dLinux联盟
sub decompilerx2dLinux联盟
{x2dLinux联盟
    my $chmfile = $_[0];x2dLinux联盟
    my $tmp = "temp";x2dLinux联盟
    while (-e "$tmp.chm" or -d $tmp){x2dLinux联盟
        my $i=1;x2dLinux联盟
    $tmp = $tmp.$i;x2dLinux联盟
    $i++;x2dLinux联盟
    }    x2dLinux联盟
    die "Cannot open file $chmfile" unless (-e $chmfile);x2dLinux联盟
    x2dLinux联盟
    copy($chmfile,"$tmp.chm") or die "Copy failed: $!";x2dLinux联盟
    x2dLinux联盟
    mkdir ("$tmp") or die "Cannot create temp!";x2dLinux联盟
    `hh.exe -decompile $tmp $tmp.chm`;x2dLinux联盟
    my $tm = basename($chmfile);x2dLinux联盟
    my $html_dir;x2dLinux联盟
    if ($tm =~ m@(.+)\.chm@i){x2dLinux联盟
    $html_dir = $1;x2dLinux联盟
    }x2dLinux联盟
    move("$tmp",$html_dir);x2dLinux联盟
    unlink ("$tmp.chm");x2dLinux联盟
}x2dLinux联盟
x2dLinux联盟
foreach(@ARGV){x2dLinux联盟
    my @chmfile = glob $_;x2dLinux联盟
    foreach $file(@chmfile){x2dLinux联盟
        print "正在反编译 $file,请稍候...\n";x2dLinux联盟
        decompiler($file);x2dLinux联盟
        print "文件$file编译完成。\n"x2dLinux联盟
    }   x2dLinux联盟
}   
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·Linux操作系统下安装Perl脚本语言的方法  (2007-08-17 10:05:52)
 ·如何利用程序循环来控制Perl脚本流程  (2006-10-29 12:50:24)
 ·perl脚本中的一些安全问题  (2006-08-26 10:28:30)