我只是 perl 的初学者并编写了一小段代码。添加 \n 后,我收到以下错误。请在下面找到表格格式。我正在尝试在索引后从 temp.txt 获取(第 2 列和第 3 列)。我试图忽略前两行。
正如我所提到的,当我将 \n 添加到代码中时出现错误
Error : Use of uninitialized value in concatenation (.) or
string at temp.pl line 10, <$fh2> line 300.
#! /usr/bin/perl
use strict;
use warnings;
my @data;
open(my $fh2,'<',"temp.txt") or die "Could not open file";
while(my $line =<$fh2>){
@data =split(/\s+/,$line);
print "$data[2] $data[3]";
print "\n";
}
Table format is:
$DATA1 SOURCE='XtA' VERSION='G-2014.06'
.TITLE '%curve%'
index temp1 temp2 temp3
alter#
1 -1.5750000e+00 -3.2053667e+00 -4.0000000e+01
1.0000000e+00(temp4)
2 -1.5272727e+00 -2.9323414e+00 -4.0000000e+01
1.0000000e+00
3 -1.4795454e+00 -2.6579232e+00 -4.0000000e+01
1.0000000e+00
....................................upto 99
temp1 temp2
<val1> <val2>