Anees 写道:
>
> #!/usr/bin/perl
> $maxRecords=20000;
> $steps=100;
>
> $index=1;
> $recCounter=0;
> while (<> && defined){
This is not right.
defined is equal to defined($_), but here $_ go without value.
For reading a file line by line, saying:
while(<>) { ... }
is enough.
while(<>) {
if (defined) {...}
}
this defined is useless. b/c if $_ is undefined in while(), the loop
will be broken already.
I guess you want to exclude the blank lines, then just say:
next if /^$/;
> if($recCounter > $maxRecords){ break; }
break is a wrong statement.
You should replace "break" with "last" here, perl does it not the same as C.
> $index++;
> }
You could never use a explict variable for keeping the line number, perl
has the built-in variable "$." for that purpose. see "perldoc perlvar".
HTH.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/