Here's another version. Just change <DATA> to <> to read from stdin. #!/usr/bin/perl -w while (<DATA>) { print if / object-group (\S+).*? object-group (\S+).*? log/ && $1 eq $2; } __DATA__ access-list dmz extended permit ip object-group SOMETHING1 object-group SOMETHING1 log access-list dmz extended permit ip object-group SOMETHING1 noise object-group SOMETHING1 log access-list dmz extended permit ip object-group SOMETHING1 object-group SOMETHING2 log access-list dmz extended permit ip object-group SOMETHING1 log Patrick McCabe Quoting John Trammell <johntrammell at gmail.com>: > On Fri, Dec 10, 2010 at 6:43 PM, Jay Austad <austad at signal15.com> wrote: >> Hmm, here's what I have, and I'm getting a "use of unitialized >> value" error for s1 and s2: >> >> #!/usr/bin/perl -w >> while (my $line = <STDIN>) { >> ($s1,$s2) = $line =~ m/.*object-group (\S*).*object-group (\S*)/; >> if ( $s1 eq $s2 ) { >> print $line; >> } >> } > > Sure, you're still comparing $s1 to $s2 even if the match fails. You > can ignore the warning, or only compare if the match hits: > > if ($line =~ /.*object-group (\S*).*object-group (\S*)/) { > print $line if $1 eq $2; > } > > You might also want to use captures like (\S+) to ensure some string > is there. > > _______________________________________________ > TCLUG Mailing List - Minneapolis/St. Paul, Minnesota > tclug-list at mn-linux.org > http://mailman.mn-linux.org/mailman/listinfo/tclug-list >