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:
>
> #!/usr/bin/perl
>
> use Tie::File;
> use File::Copy 'copy';
> use File::Spec;
>
>
> and further down, it has:
>
> # Tie it to an array
> #
> (my $copy = $htmfile) =~ s/(\.htm)\z/-Copy$1/i;
> copy $htmfile, $copy;
> tie my @hfile, 'Tie::File', $copy;
> tie my @bfile, 'Tie::File', $recapfile;
>
> ## hfile is the array of the lines of htmfile
> #
> print "$copy \n";
> print "hfile: 1--$hfile-- \n";
>
> $copy's value is correct.
>
> I'm on a Windows 7 machine. Should I have the Windows full pathname for
> perl.exe at the top????
>
> Happy to send the entire script to anyone who would like to see it.
>
> Thanks.
>
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/
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!!!
????
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/