# compare two array

**URL:** <https://community.unix.com/t/compare-two-array/307331>\
**Category:** Shell Programming and Scripting\
**Created:** [March 28, 2012, 11:05am UTC](https://community.unix.com/t/compare-two-array/307331 "2012-03-28T11:05:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renesh](https://community.unix.com/letter_avatar/renesh/32/6_449c533f586939b6e5f246632a46421f.png) [@Renesh](https://community.unix.com/u/Renesh)\
**Post date:** [March 28, 2012, 11:05am UTC](https://community.unix.com/t/compare-two-array/307331/1 "2012-03-28T11:05:14Z")

</div>

Hi firnds,

I am having two arrays  
eg. @a=qw(1 2 3 4) and @b=qw(1 3 6 9)  
Now, I want to compare two arrays on first index of both arrays and if they matched, it should output remaining indexes  
Pseudo-code  
if ($a[0] == $b[0])  
{ print "remaining indexes";}

How can i do this using perl?

---

<div class="post-metadata">

**Author:** ![joeyg](https://community.unix.com/user_avatar/community.unix.com/joeyg/32/780_2.png) [@joeyg](https://community.unix.com/u/joeyg)\
**Post date:** [March 28, 2012, 11:07am UTC](https://community.unix.com/t/compare-two-array/307331/2 "2012-03-28T11:07:54Z")

</div>

Bumping up posts or double posting is not permitted in these forums.

Please read the [rules](http://www.unix.com/misc.php?do=cfrules), which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
