This may do what you want foreach (@ACL) { if (/ object-group (\w+).*object-group (\w+)/) { if ("$1" eq "$2") { print "$_\n"; } } } On Fri, 2010-12-10 at 17:40 -0600, Jay Austad wrote: > 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 > > > > > > _______________________________________________ > TCLUG Mailing List - Minneapolis/St. Paul, Minnesota > tclug-list at mn-linux.org > http://mailman.mn-linux.org/mailman/listinfo/tclug-list -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20101210/a7be6e11/attachment.htm