请教一个perl语言编程引用的问题

软件和网站开发以及相关技术探讨
回复
weasteam
帖子: 51
注册时间: 2007-07-14 14:43

请教一个perl语言编程引用的问题

#1

帖子 weasteam » 2009-02-19 11:53

大家好,我现在遇到这么一个问题:

我电脑里装了一个叫做unafold.pl的程序,,其在命令行下可以以unafold.pl [file]的方式执行并在当前目录下产生结果文件。
此程序没有指定特别的输出目录,所有的输出文件都是命令行下的目录

我在用perl语言调用此程序后,想把unafold.pl产生的文件放入一个特定的文件夹,但总是不能成功,因为所有文件被放入我的 perl程序的目录。

请问如何实现更改unafold.pl的输出文件位置?

It is because the unafold.pl will output its files under the path of
given commend, eg. we open the terminal at /home/weasteam like this
"~$" and run "UNAFold.pl /home/weasteam/hiv/hiv.fas" the new files
will be output in /home/weasteam, but not in /home/weasteam/hiv/. In
my perl software, the folder where the software located will be
considered as such path and all unafold files will be pushed in this
folder which make our software unable to read the unafold files.

I have tried to use <system "cd path"> in perl to change the terminal
path but failed, do anyone have any suggestions to call one commend with
perl and specify the path of its output files? (ps, I have checked the
option of unafold.pl, in which no information about output path have
been mentioned.)
上次由 weasteam 在 2009-02-19 12:23,总共编辑 1 次。
poet
帖子: 2841
注册时间: 2006-09-11 22:47

Re: 请教一个perl语言编程引用的问题

#2

帖子 poet » 2009-02-19 12:03

> 我在用perl语言调用此程序后,想把unafold.pl产生的文件放入一个特定的文件夹,但总是不能成功,因为所有文件被放入我的 perl程序的目录。

你想怎么放?究竟什么叫“不能成功”,你做了什么操作?得到什么提示?

学会google“提问的智慧”并阅读,你的问题会有效率得多。
weasteam
帖子: 51
注册时间: 2007-07-14 14:43

Re: 请教一个perl语言编程引用的问题

#3

帖子 weasteam » 2009-02-19 12:23

poet 写了:> 我在用perl语言调用此程序后,想把unafold.pl产生的文件放入一个特定的文件夹,但总是不能成功,因为所有文件被放入我的 perl程序的目录。

你想怎么放?究竟什么叫“不能成功”,你做了什么操作?得到什么提示?

学会google“提问的智慧”并阅读,你的问题会有效率得多。
It is because the unafold.pl will output its files under the path of
given commend, eg. we open the terminal at /home/weasteam like this
"~$" and run "UNAFold.pl /home/weasteam/hiv/hiv.fas" the new files
will be output in /home/weasteam, but not in /home/weasteam/hiv/. In
my perl software, the folder where the software located will be
considered as such path and all unafold files will be pushed in this
folder which make our software unable to read the unafold files.

I have tried to use <system "cd path"> in perl to change the terminal
path but failed, do anyone have any suggestions to call one commend with
perl and specify the path of its output files? (ps, I have checked the
option of unafold.pl, in which no information about output path have
been mentioned.)
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 请教一个perl语言编程引用的问题

#4

帖子 eexpress » 2009-02-19 12:45

$0取得程序路径。。。在设置一个输出的路径。
只是$0不一定是全路径。
● 鸣学
weasteam
帖子: 51
注册时间: 2007-07-14 14:43

Re: 请教一个perl语言编程引用的问题

#5

帖子 weasteam » 2009-02-19 13:28

eexpress 写了:$0取得程序路径。。。在设置一个输出的路径。
只是$0不一定是全路径。
谢谢eexpress,,我还是不清楚如何设置一个输出路径?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 请教一个perl语言编程引用的问题

#6

帖子 eexpress » 2009-02-19 13:57

?? 没理解你意思
open一个指定路径的文件而已啊。修改保存。
open(BM, "$home/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml")
● 鸣学
weasteam
帖子: 51
注册时间: 2007-07-14 14:43

Re: 请教一个perl语言编程引用的问题

#7

帖子 weasteam » 2009-02-19 14:16

谢谢楼上两位,,我查到解决方法了,,

具体方法如下:

代码: 全选

use File::chdir;
$CWD = "/home/wu/b/R/datas/program/mi/test/ebv/";     # now in /foo/bar
system "UNAFold.pl ebv.fas";
成功!!!
我的perl程序在/home/wu/b/R/datas/program/mi/test/下,,调用system "UNAFold.pl [file]"时总是在/home/wu/b/R/datas/program/mi/test/目录产生文件,,但我想让它的文件产生在/home/wu/b/R/datas/program/mi/test/ebv/下面,,终于发现安装一个File::chdir就可以搞定。

再次谢谢
头像
RegentW
帖子: 1486
注册时间: 2007-02-27 21:47
来自: NN

Re: 请教一个perl语言编程引用的问题

#8

帖子 RegentW » 2009-04-02 9:21

不鼓励这样做 可以修改一下UNAFold.pl 并不难吧
Core i5, 512G + SSD 20G, DDRIII 8G
wfnh
帖子: 84
注册时间: 2008-02-20 11:46
联系:

Re: 请教一个perl语言编程引用的问题

#9

帖子 wfnh » 2009-12-16 21:07

你可以直接在命令行上输入你要保存的目录啊···解析一下参数就行了···改一下脚本很容易实现
回复