DATSUN_BLUE TOYOTA_MAROON ELANTRA-YELLOW #### 1250 1 engineer office DATSUN_BLUE office 67 page30 text 1500 1 billing office MERCEDES-TAN office 98 page 40 txt 1500 7 billing office JAGUAR-BLACK office 98 page 40 txt 1250 0 engineer office ELANTRA_YELLOW office 66 page50 txt 1250 1 engineer office DATSUN_BLUE office 67 page30 text #### open my $fh2, '<', '/tmp/location' or die "unable to open file for reading : $!"; open my $fh1, '<', '/tmp/carlist' or die "unable to open file for reading : $!"; chomp(my @carlist = <$fh1>); print "these are the policies @carlist\n"; close $fh1; my $pattern = join '', @carlist; my @strings; while (<$fh2>) { my @fields = split(',', $_); local $" = ','; if ( $fields[1] eq '1' || $fields[1] eq '0') { push @strings, $_ if /$pattern/; print $fh3 "@fields[0,4]\n" if /engineer/ && !/,-,/; } } close $fh2; close $fh1; close $fh3;