在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3715|回复: 4

[求助] 用perl 如何处理包含特殊符号的文件名?

[复制链接]
发表于 2013-6-25 09:59:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
用perl 查找某目录下包含 .xls后缀的文件,然后调用excel打开。对某些 包含()的,比如 temp(20130624).xls  ,打开不了?


请问要怎么处理?
发表于 2013-6-25 10:47:20 | 显示全部楼层
回复 1# litaohqqt

   In order to invoke the file name contains special charecters, the single quotes will be helpful.
   Here is the script for you:

   #!/usr/bin/perl
   @files = `ls`;
   foreach $file (@files) {
       chomp($file);
       if ($file =~ /^(.*\.xls)$/ ) {
          system "openooffice.org3 '$file'";
       }
   }
 楼主| 发表于 2013-6-25 19:36:35 | 显示全部楼层
多谢 Neil_10 !

问题已经解决! 原因不明。
用use Spreadsheet:arseExcel; 可以
用use Win32::OLE; 打不开文件,可以新建文件。


还有个问题, 怎样实现解压缩 .rar 文件?
use Archive::Zip 现在能解压 .zip 文件,但不知道用那个解压rar?
 楼主| 发表于 2013-6-27 09:35:30 | 显示全部楼层
新手问题。主要是对PPM不是很熟。
现在已经解决zip,rar等压缩文件,解压成xls 进行汇总处理。

use Getopt:ong;
use File::Basename;

use Archive::Zip;
use Archive::Zip::Tree;
use Archive::Unrar;
use Cwd;
use File::Copy;
use Unicode::Map();

use Spreadsheet:arseExcel;
use Spreadsheet:arseExcel::FmtUnicode;
my $oFmtC = Spreadsheet:arseExcel::FmtUnicode->new(Unicode_Map=>"CP936");
发表于 2013-6-27 10:30:01 | 显示全部楼层
[i=s] 本帖最后由 sjtusonic 于 2013-6-27 10:33 编辑 [/i]

发帖时把这3个打勾,可以避免一些奇怪的符号:  禁用 URL 识别 禁用 Smilies 禁用 Discuz!代码  TEST:   use Getopt::Long;
use File::Basename;

use Archive::Zip;
use Archive::Zip::Tree;
use Archive::Unrar;
use Cwd;
use File::Copy;
use Unicode::Map();

use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::FmtUnicode;
my $oFmtC = Spreadsheet::ParseExcel::FmtUnicode->new(Unicode_Map=>"CP936");
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-19 14:57 , Processed in 0.025135 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表