G'day Frits,
I'm familiar with grep, egrep and fgrep but not ggrep. Please provide a link to documentation or a brief description of how it differs from grep.
Here's how you can do the "multi grep and grep exclude" part:
grep { /Country/ && /City1/ && /Street1/ && ! /name1/ } ...
"this grep will be in a foreach loop"
Why? Please provide some code to show what you're doing.
As already stated by others, your requirements are unclear. Here's my best guess as to the type of thing you want.
#!/usr/bin/env perl -l use strict; use warnings; while (<DATA>) { if ((my $result) = grep { /Country/ && /City1/ && /Street1/ && ! / +name1/ } $_) { print +(split ' ', $result)[4]; last; } } __DATA__ Country City Street1 number1 name1 Country City1 Street1 number1 name2 Country City1 Street1 number2 name3 Country City1 Street2 number1 name4 Country City1 Street2 number1 name5
Output:
name2
— Ken
In reply to Re: Need to multi grep and grep exclude in perl.
by kcott
in thread Need to multi grep and grep exclude in perl.
by Frits
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |