R56 has asked for the wisdom of the Perl Monks concerning the following question:
Hey all! Hoping someone can help me solve a little problem.
I'm parsing a block of free text in a file, and I have a pre-loaded array of specific terms.
When I parse that block of text into a string, I'm looking to cross reference each word on that string with the terms I have on the array. If there's a match between the two, print it out.
if($text =~ /upperboundary(.+)lowerboundary/s){ if(grep {$_ eq $1} @terms){ print OUT "$1\t"; } }
This doesn't work, and I searched for a while on how to do it, to no avail. Can someone point me in a better direction? Thanks in advance!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Comparing string to array elements
by LanX (Saint) on Jan 11, 2017 at 18:11 UTC | |
by R56 (Sexton) on Jan 11, 2017 at 18:55 UTC | |
by toolic (Bishop) on Jan 11, 2017 at 19:04 UTC | |
by R56 (Sexton) on Jan 13, 2017 at 14:58 UTC | |
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 | |
Re: Comparing string to array elements
by LanX (Saint) on Jan 11, 2017 at 18:17 UTC | |
Re: Comparing string to array elements
by Lotus1 (Vicar) on Jan 11, 2017 at 21:52 UTC | |
by R56 (Sexton) on Jan 13, 2017 at 15:07 UTC | |
by Lotus1 (Vicar) on Jan 13, 2017 at 16:04 UTC | |
by R56 (Sexton) on Jan 14, 2017 at 02:49 UTC |
Back to
Seekers of Perl Wisdom