Perl Script needed to be reversed to output matching, not non-matching

view full story

http://www.linuxquestions.org – I am having a rough time attempting to reverse this tiny script to outfile matching fields. It only outfiles the non-matching. I tried playing with the regular expressions and of course it did not work. Could someone give me some insight as to how to make this reverse its role and outfile matching fields? Thanks! Code: #!/bin/perl use strict; use warnings; my $f1 = 'file2'; my $f2 = 'hosts'; my $outfile = 'hosts1'; my %results = (); open FILE1, "$f1" or die; while(my $line = <FILE1>){ (HowTos)