电脑在windows下写了一个perl脚本,是关于数据的的读取和输出的,但是在CMD上运行程序后没显示结果和报错

代码如下:
#!/usr/bin/perl
# reading protein sequence data from a file

#First we have to open file and associate a "filehandle" with it, we choose the
#filehandle PROTEINFILE for readability.
open(PROTEINFILE, "pep.txt");

#first line
$protein=<PROTEINFILE>;

#print the protein onto the screen
print ("$protein");

#second line
$protein =<PROTEINFILE>;

#print the protein onto the screen
print ("$protein");

#third line
$protein =<PROTEINFILE>;

#print the protein onto the screen
print ("$protein");

#now we can close the file
close (PROTEINFILE);
#代码应该没多大问题,在CMD上运行的结果显示如图

输入 perl test.pl 然后就能执行了。其中test.pl是你所要运行的文件的名称用命令指示符则说不是内部或外部的命令。这个说明安装没有自动把perl的文件路径自动添加到环境变量中去。具体方法:右击我的电脑--属性--高级--环境变量--在系统变量部分--双击path--在最后添加你perl的安装路径。例如;C:\Perl\bin 另外一种方法,你也可以安装activeperl 5.10.0 它会自动添加环境变量
温馨提示:答案为网友推荐,仅供参考
相似回答