【发布时间】:2022-01-22 19:54:46
【问题描述】:
我正在使用 vs 代码学习 Perl。 我正在尝试打开文件 .pep 并从中读取,但每次我发现找不到路径。 我已将 protein.pep 和 code.pl 放在同一个文件夹中。
这里是 protein.pep 文件
MNIDDKLEGLFLKCGGIDEMQSSRTMVVMGGVSGQSTVSGELQD
SVLQDRSMPHQEILAADEVLQESEMRQQDMISHDELMVHEETVKNDEEQMETHERLPQ
GLQYALNVPISVKQEITFTDVSEQLMRDKKQIR
使用路径 D:\bioinformatics\protein.pep
这是我的 code.pl 文件
#!/usr/bin/perl -w
$proteinfilename = 'protein.pep';
open(PROTEINFILE, $proteinfilename)or die "Can't open '$seq': $!";
# First line
$protein = <PROTEINFILE>;
# Print the protein onto the screen
print "\nHere is the first line of the protein file:\n\n";
print $protein;
# Second line
$protein = <PROTEINFILE>;
# Print the protein onto the screen
print "\nHere is the second line of the protein file:\n\n";
print $protein;
# Third line
$protein = <PROTEINFILE>;
# Print the protein onto the screen
print "\nHere is the third line of the protein file:\n\n";
print $protein;
它的路径是D:\bioinformatics\code.pl
我得到这个输出“系统找不到指定的路径。”
【问题讨论】:
-
是这条线
open(PROTEINFILE, $proteinfilename)or die "Can't open '$seq': $!";给出了错误吗?顺便提一句。$seq未定义 -
我还建议使用Three-arg open() 而不是老式的两个参数
-
不是错误,是输出
-
ok,但是也可以输出错误。尝试确定脚本的哪一行产生了输出
-
我会在我的问题中附上一张代码图片,请检查一下
标签: perl