#!/usr/bin/perl use strict; use warnings; use feature qw/say/; # I'm assuming you can't control how @flab is populated. my @flab; push @flab, "name_$_\ttitle_$_" for (1..200); # turn @flab into a hash my %titles = (); foreach (@flab) { my ($name, $title) = split /\t/; $titles{$name} = $title; } open my $LONG_LIST, "<", "longlist.txt" or die "Cannot open file: $!"; say "Company\tName\tTitle"; while (<$LONG_LIST>) { chomp; my ($company, $name) = split /\t/;; say "$company\t$name\t$titles{$name}" if($titles{$name}); }