Say I have a file full of lines that look like the following:

access-list dmz extended permit ip object-group SOMETHING1 object-group SOMETHING2  log

I need a perl script that takes in each line, compares SOMETHING1 to SOMETHING2, and then prints the original line ONLY if they match.  Not all of the lines have the same number of columns, and I also need to ignore lines that only have one "object-group" in them.

I'm thinking some sort of regex like this would work, but I'm unsure how to impelment, and need to get this done fast:
/ object-group (\S+).+object-group (\S+)/

I think that's how you pull matches out of a regex, but I forgot how to reference them, or even to check my $line variable against them that is populated while going through a while loop.

Can someone help?  I'm really in a pinch.

Thanks!

~jay