# Perl grep array against array

**URL:** <https://community.unix.com/t/perl-grep-array-against-array/248180>\
**Category:** Shell Programming and Scripting\
**Created:** [August 29, 2009, 7:54am UTC](https://community.unix.com/t/perl-grep-array-against-array/248180 "2009-08-29T07:54:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![King\_Nothing](https://community.unix.com/letter_avatar/king_nothing/32/5_5575768a8748004e209b776fc1b2916d.png) [@King\_Nothing](https://community.unix.com/u/King_Nothing)\
**Post date:** [August 29, 2009, 7:54am UTC](https://community.unix.com/t/perl-grep-array-against-array/248180/1 "2009-08-29T07:54:20Z")

</div>

Hi,  
Is there any way I can grep an array against another array?

Basically here's what I need to do.

There will be an array containing some fixed texts and I have to check whether some files contain these lines. Reading the same files over and over again for each different pattern doesnt seem to be the best of ways.  
Once a match is found, I need to do some further processing on the line containing the pattern and map it against the pattern found.

Thank You.

---

<div class="post-metadata">

**Author:** ![Vi-Curious](https://community.unix.com/letter_avatar/vi-curious/32/5_5575768a8748004e209b776fc1b2916d.png) [@Vi-Curious](https://community.unix.com/u/Vi-Curious)\
**Post date:** [August 29, 2009, 8:45am UTC](https://community.unix.com/t/perl-grep-array-against-array/248180/2 "2009-08-29T08:45:37Z")

</div>

Check Perl's grep function. Even if you can't make exact use of it, just seeing what it does should be enough to help you. A simple iteration over your arrays will allow you to do what you want.
