#!/usr/bin/perl -w
use 5.010;
open my ($points),'<','points.txt'
or die "couldn't read points data: $!\n";
while (<$points>) {
next if /^\s*#.*$/; #跳过注释
push @xyz,[split];
}
foreach my $pt (@xyz) {
print "point ",$i++,": x=$pt->[0],y=$pt->[1], ","z = $pt->[2]\n";
}
points.txt文件内容为:
#点坐标数据
1 2 3
4 5 6
7 8 9