#!/usr/bin/perl use warnings; use strict; use Text::CSV; my %record; my $csv = 'Text::CSV'->new({ sep_char => "\t", eol => "\n", }); open my $CSV, '<', 'file.csv' or die $!; while (my $row = $csv->getline($CSV)) { $record{ $row->[0] } = $row; } open my $LST, '<', 'ids.lst' or die $!; my %id; while (<$LST>) { chomp; print $record{$_} if exists $record{$_}; }