On Jul 29, 2014, at 5:12 PM, ESChamp <esch...@gmail.com> wrote:

> ESChamp wrote on 7/28/2014 6:59 PM:
>> Suddenly, without warning or error messages, the script below is
>> producing null for values of $hfile and $bfile!
>> 
>> The script begins:
>> 
>> 
> 
> Let me backtrack and provide some background information.
> 
> This script processes two files, recapfile, a plain text file, and copy,
> and HTML-formatted file.
> 
> It reads copy into an array, and recapfile into another array. Then it
> writes a new array which contains all the initial lines of the recapfile
> array from the first line down to but not including the first line
> containing / RESULTS OF BOARD 1/

Most of that information is superfluous. You need to concentrate on the precise 
problem that you are having.

> 
> And here is where it goes wrong ('No <pre> found')
> 
> ($index) = grep $hfile[$_] eq '<pre>', 0 .. $#hfile;
> die 'No <pre> found' unless $index;
> 
> I printed hfile using
>       foreach (@hfile) { print "$_\n"; }
> 
> and it looks fine! That is, there is a line with only <pre> on it!!!

Perhaps the line containing ‘<pre>’ contains whitespace characters that you 
cannot see when you print it. If so, you can replace you exact test with a 
regular expression:

  if( grep /<pre>/ @hfile ) {
    …
  }

Or maybe <pre> occurs on the first line, in which case $index will have the 
value 0, which is treated as false, and your program will die.

This is all speculation because you have not provided us with your exact 
program and data files.


--
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