#!/usr/bin/env perl use strict; use warnings; my %data; while () { next if $. == 1; chomp; next unless length; my ($k, $v) = split; $data{$k} = $v; } # To test result use Data::Dumper; print "*** Hash ***\n"; print Dumper(\%data); print "*** Keys ***\n"; print "$_\n" for keys %data; print "*** Values ***\n"; print "$_\n" for values %data; __DATA__ GeneName GeneType APOL4 protein_coding CYP2C8 protein_coding NAALADL2 protein_coding NANOS3 protein_coding C20orf204 protein_coding MIR429 miRNA MIR200A miRNA MIR200B miRNA