无法打开文件?
时间:2011-07-21
来源:互联网
先上代码:
复制代码
前两个keyword输入无问题,在进行$documentinput录入时输入D:/test.txt并回车后提示:
cant open input file D:/test.txt
test.txt确定存在
谢谢大家!
- #1.Choose the input and output file
- print "please input the keyword1 you wanna chop off(the line contained the keyword would be deleted!)";
- $Keyword1 = <STDIN>;
- chomp $Keyword1;
- print "please input the keyword2 you wanna chop off(the line contained the keyword would be deleted!)";
- $Keyword2 = <STDIN>;
- chomp $Keyword2;
- print "please type in the document you wanna read in: \n";
- $documentinput = <STDIN>;
- chomp $documentinput;
- unless(open(FH,'$documentinput') ){
- print "cant open input file $documentinput";
- exit;
- }
- print "please type in the document you wanna write in: \n";
- $documentoutput = <STDIN>;
- chomp $documentoutput;
- unless(open(FH2,">$documentoutput")){
- print "cant find output file $documentoutput";
- exit;
- }
-
- #2.Take out every line of the txt document to $Content in order and check if key word is in $Content
- while($Content=<FH>){
- if($Content =~ /$Keyword1/){
- print FH2 ''}
- elsif($Content =~ /$Keyword2/){
- print FH2 ''}
- else{print FH2 $Content}
- }
- close FH;
- close FH2;
- print "Mission Complete! please close this window and chech the write-in document.";
- sleep
cant open input file D:/test.txt
test.txt确定存在
谢谢大家!
作者: shinra13 发布时间: 2011-07-21
自己搞定,多了一对引号。
这帖子咋删啊。。
这帖子咋删啊。。
作者: shinra13 发布时间: 2011-07-21
QUOTE:
先上代码:前两个keyword输入无问题,在进行$documentinput录入时输入D:/test.txt并回车后提示:
cant ope ...
shinra13 发表于 2011-07-21 01:06
cant ope ...
shinra13 发表于 2011-07-21 01:06
要命的错误....
unless(open(FH,'$documentinput') ){
作者: jason680 发布时间: 2011-07-21
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28