免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1976 | 回复: 1
打印 上一主题 下一主题

Use of uninitialized value $period的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-04 21:25 |只看该作者 |倒序浏览
大家好,我是个Perl的初学者,在用Perl来写让电脑作图的程序时,遇到了一个问题无法解决。当我用Windows的Command line来运行时,提示的错误信息如下:
Use of uninitialized value $period in substitution <s///> at graph_gp_select.pl line 8, <TMP> line 1.
Use of uninitialized value $period in concatenation <.> or string at graph_gp_select.pl line 14.
程序的代码如下:
#!/usr/bin/perl -w
# Read in the data from files
#reads inn serial number from Fortran run from file "tmp"
open TMP, "tmp";
my $title_text = <TMP>;
my $period = <TMP>;
$title_text =~ s/\s//g;
$period =~ s/\s//g;
close TMP;

my $plotfile = $title_text.'.txt';

my $outputfile =$title_text.'_conc_select.png';
$title_text = $title_text.'; period = '.$period; (Line 14)


open (GNUPLOT, '|pgnuplot') or die "open: $!"; (pgnuplot是我用的作图软件)

print GNUPLOT <<EOF;

set terminal png

set title "$title_text"
set pointsize 2.0
set xtic
set mxtics 0.1
set ytics
set y2tics
set mytics 5

set xlabel "time, a.u."
set ylabel "nr, NR, NO3-, NMR, NO3_set (au)"
set y2label "NIT2:NIT4 (au), promoter saturation ratio (psr)"  

set grid


set output 'graph_select.png'
plot "$plotfile" usi 1:2 title "nr" w lines, "$plotfile" usi 1:3 title "NR"  w lines, "$plotfile" usi 1:4 title "NO3-" w lines,  "$plotfile" usi 1:8 title "NMR"  w lines, "$plotfile" usi 1:9 title "NIT2:NIT4"  axes x1y2 w lines, "$plotfile" usi 1:10 title "psr"  axes x1y2 w lines, "$plotfile" usi 1:11 title "NO3_set"  w lines
set output "$outputfile"
plot "$plotfile" usi 1:2 title "nr" w lines, "$plotfile" usi 1:3 title "NR"  w lines, "$plotfile" usi 1:4 title "NO3-" w lines,  "$plotfile" usi 1:8 title "NMR"  w lines, "$plotfile" usi 1:9 title "NIT2:NIT4"  axes x1y2 w lines, "$plotfile" usi 1:10 title "psr"  axes x1y2 w lines, "$plotfile" usi 1:11 title "NO3_set"  w lines
EOF

#unlink ("tmp");


close (GNUPLOT) or die "close!";
请哪位朋友帮我查一下,谢谢了!

论坛徽章:
46
15-16赛季CBA联赛之四川
日期:2018-03-27 11:59:132015年亚洲杯之沙特阿拉伯
日期:2015-04-11 17:31:45天蝎座
日期:2015-03-25 16:56:49双鱼座
日期:2015-03-25 16:56:30摩羯座
日期:2015-03-25 16:56:09巳蛇
日期:2015-03-25 16:55:30卯兔
日期:2015-03-25 16:54:29子鼠
日期:2015-03-25 16:53:59申猴
日期:2015-03-25 16:53:29寅虎
日期:2015-03-25 16:52:29羊年新春福章
日期:2015-03-25 16:51:212015亚冠之布里斯班狮吼
日期:2015-07-13 10:44:56
2 [报告]
发表于 2010-10-04 21:52 |只看该作者
本帖最后由 zhlong8 于 2010-10-04 21:57 编辑

open TMP, "tmp";
my $title_text = <TMP>;
my $period = <TMP>;

这里按你的第一个错误提示就是说执行到这里 $period 根本没有读取任何内容,因为 $title_text 没有报错,初步判定为你的文件只有一行,所以 $peroid 根本读不到任何内容。另外你 open 的时候没有检察系统错误,试下加上 open TMP, '<', 'tmp' or die $!;

暂时就想到这两个原因
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP