关于perl输出到文本的一个诡异问题
时间:2011-03-24
来源:互联网
现在我打算读入一个文本文件,然后存到数组里面去,进行一定修改以后存到另外一个文本里面去。我用了printf,整个内容都转过去了没错,但是一直有warning,
use of uninitialized value.
大家帮忙看看咋回事呢。谢谢!
#!/usr/bin/env perl -w
use strict;
open (FILE,"$ARGV[0]") or die "error in opening file $!\n";
my @output = <FILE>;
close FILE;
open (FILE, ">test.out1") or die "error in opening file $!\n";
for (my $i=0; $i<@output; $i++){
printf FILE $output[$i];
}
最初的文本文件大概是这样的:
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01ARQHR
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01ARQHR Geranium_palmatum: 100.00 92 0 0 21 112 124834 124925 7e-48 182
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01AI4KO
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01AI4KO Geranium_palmatum: 96.97 99 0 3 13 111 124293 124198 1e-37 149
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01ANXUE
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01ANXUE gene:rps8_42661_43065_Geranium_palmatum: 99.25 134 0 1 15 147 232 99 3e-68 250
FBO9Y7B01ANXUE Geranium_palmatum: 99.25 134 0 1 15 147 42892 42759 3e-68 250
local multiple blast的输出结果,基本上是一个query一个warning。
use of uninitialized value.
大家帮忙看看咋回事呢。谢谢!
#!/usr/bin/env perl -w
use strict;
open (FILE,"$ARGV[0]") or die "error in opening file $!\n";
my @output = <FILE>;
close FILE;
open (FILE, ">test.out1") or die "error in opening file $!\n";
for (my $i=0; $i<@output; $i++){
printf FILE $output[$i];
}
最初的文本文件大概是这样的:
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01ARQHR
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01ARQHR Geranium_palmatum: 100.00 92 0 0 21 112 124834 124925 7e-48 182
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01AI4KO
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01AI4KO Geranium_palmatum: 96.97 99 0 3 13 111 124293 124198 1e-37 149
# BLASTN 2.2.20 [Feb-08-2009]
# Query: FBO9Y7B01ANXUE
# Database: Geranium_palmatum
# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
FBO9Y7B01ANXUE gene:rps8_42661_43065_Geranium_palmatum: 99.25 134 0 1 15 147 232 99 3e-68 250
FBO9Y7B01ANXUE Geranium_palmatum: 99.25 134 0 1 15 147 42892 42759 3e-68 250
local multiple blast的输出结果,基本上是一个query一个warning。
作者: mooncake2010 发布时间: 2011-03-24
补充一下,问题出在第四行# Fields: Query id, Subject id, 0dentity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
printf输出的时候会同时报错,uninitialized value...
printf输出的时候会同时报错,uninitialized value...
作者: mooncake2010 发布时间: 2011-03-24
大概知道是什么问题了,第四行里面有个%,perl printf的时候把这个%当成格式符号了,但是后面又么有数字跟着,所以他就报错了,输出到文本变成一个0,大家知道这种问题怎么解决吗?
作者: mooncake2010 发布时间: 2011-03-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28