John W. Krahn wrote on 7/31/2014 3:11 AM:
> Peter Holsberg wrote:
>> I think I've isolated the section that is not doing what I want.
>>
>> open (FHIN, "$recapfile") or die $!;
> 
> That would be better as:
> 
> open my $FHIN, '<', $recapfile or die "Cannot open '$recapfile' because: 
> $!";

Thanks, John. As this is a beginners list and I'm an elderly beginner
who is an occasional perl user, what makes that better?

>> my $indexb; ## for the recapfile array
>> my $ofile;
> 
> You never use this variable, it should be:
> 
> my @ofile;

Could you kindly explain that?

>> # Create new array containing all the lines of recapfile up to
>> # the string RESULTS OF BOARD 1
>>
>> XYZZY:
>>      while (<FHIN>)
>>      {
>>              last XYZZY if  / RESULTS OF BOARD 1/;
>>              chomp;
>>              $ofile[$indexb++] .= $_;
> 
> That would be better as:
> 
>      push @ofile, $_;
>>      }
>> close FHIN;

Exactly what lines would yours replace? Why would that be better?


>> To see what was put into ofile, a line at a time, I used
>>
>> foreach (@ofile) {
>>    print "$_\n";
>> }
>>
>> Is that correct?
> 
> That is correct.

:-) I did something right! :-)

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to