Dear friends:
I am a perl begineer. I have created an script which prints each 100th
record from the file as shown below:
#!/usr/bin/perl
$maxRecords=20000;
$steps=100;
$index=1;
$recCounter=0;
while (<>){
if(defined) {
if (($index % $steps) == 0) {
print $_;
$recCounter++;
}
if($recCounter > $maxRecords){ break; }
$index++;
}
}
The above script works fine. But when I modify the script as follows:
#!/usr/bin/perl
$maxRecords=20000;
$steps=100;
$index=1;
$recCounter=0;
while (<> && defined){
if (($index % $steps) == 0) {
print $_;
$recCounter++;
}
if($recCounter > $maxRecords){ break; }
$index++;
}
I won't give me any records.
Can you please identify the difference in behavior ?
Sincerely,
Anees Haider
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/