in reply to Re: Comparing string to array elements
in thread Comparing string to array elements
Thank you for the reply Rolf! I'm guessing I should've put all the code instead of a little snippet, as it isn't very long.
use strict; use warnings; use File::Slurp; my $countfile = 1; open (IN, 'C:\terms.txt'); my @terms = <IN>; close IN; open (OUT,'>>C:\result.txt'); while ($countfile < 10000) { my $text = read_file('C:\file' . $countfile . '.xml') or die "Can' +t open file!"; if($text =~ /upperboundary(.+?)lowerboundary/s){ if(grep {$_ eq $1} @terms) { print OUT "$1\t"; } } close IN; $countfile++; open (IN, 'C:\file' . $countfile . '.xml') or die "End of files!"; } close OUT;
I can see the array populated if I print it, but there must be some other thing that's destroying the output at the middle...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Comparing string to array elements
by toolic (Bishop) on Jan 11, 2017 at 19:04 UTC | |
by R56 (Sexton) on Jan 13, 2017 at 14:58 UTC | |
Re^3: Comparing string to array elements
by R56 (Sexton) on Jan 13, 2017 at 15:03 UTC | |
by hippo (Bishop) on Jan 13, 2017 at 15:34 UTC | |
by Lotus1 (Vicar) on Jan 13, 2017 at 21:14 UTC |
In Section
Seekers of Perl Wisdom