计算数组长度函数scalar;

有代码有真相:

#!/usr/bin/perl
open(FILE1,"C:/Perl/BX/BX-Book-Ratings_result.txt");
open(FILE2,"C:/Perl/BX/BX-Users_result.txt");
open(result1,">C:/Perl/BX/BX-Book-Ratings_short.txt");
open(result2,">C:/Perl/BX/BX-Users_short.txt");

my @ISBN;
my $isbnNum=0;
my $i=0;
my $user;
my $subString;
my $count=0;

while(($_=<FILE1>)&&($user=<FILE2>))
{
	$subString=substr($_,index($_,",")+1);
	@ISBN=split(/ /,$subString);
	$isbnNum=scalar(@ISBN);
	if($isbnNum>4)
	{
		syswrite(result1,"$_");
		syswrite(result2,"$user");
		$count++;
	}
	else
	{
		next;
	}
	#printf"@ISBN $isbnNum $user";
	#$i++;
		
}
printf"$count";
close(FILE1);
close(FILE2);
close(result1);
close(result2);

Posted on 2011-01-08 10:11  singlefold  阅读(5115)  评论(0编辑  收藏  举报