孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

#!/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

posted on 2012-09-28 22:00  孤独的猫  阅读(306)  评论(0编辑  收藏  举报