Posted on 2010-08-09 17:58
kongkongzi 阅读(420)
评论(0) 编辑 收藏 引用 所属分类:
perl
#!/usr/bin/perl -w
# file: statstxt
use strict;
if (@ARGV < 2) # @ARGV return size of array ARGV in this context
{
die "Usage: $0 intxt outfile\n";
}
my $success = open INTXT, "<", $ARGV[0]; # open function has three args, INTXT is a file handler
if (!$success)
{
die "Cannot open $ARGV[0]:$!";
}
$success = open STATSOUT, ">", $ARGV[1];
if (!$success)
{
die "Cannot open $ARGV[1]:$!";
}
while (<INTXT>)
{
my @arrCol = split(/\s+/); # $_ # split $_ by spaces
if ($arrCol[1] > 0) # The second column of text
{
print;
print STATSOUT;
}
}
close INTXT;
close STATSOUT;