#!/usr/bin/perl -CSDA use utf8; use Modern::Perl; no warnings qw{uninitialized}; use Data::Dumper; use Path::Tiny; my %myhash = map { ($$_[0], $$_[2]) } map { [split /\s+/, $_] } `cat myfile`; # maybe slower, but don't care about open # path("myfile")->lines_utf8; # very reliable print Dumper(\%myhash); result: $VAR1 = { 'AC067940.1' => 'up', 'CCT5P2' => 'up', 'GeneName' => 'Regulation', 'C20orf204' => 'up', 'NANOS3' => 'up', 'MIR200A' => 'down', 'SREK1IP1P1' => 'down', 'AC091607.1' => 'up', 'CYP2C8' => 'down', 'AL662791.1' => 'up', 'FAR1P1' => 'NA', 'MIR200B' => 'down', 'CHTF8P1' => 'NA', 'RPL19P20' => 'up', 'MIR429' => 'up', 'APOL4' => 'up', 'CFL1P4' => 'down', 'NAALADL2' => 'NA' };