#!/usr/bin/perl use warnings; use strict; my %denovo; while (my $line = ){ chomp $line; if ($line =~ /([^,]*)$/){ my $name = "$1"; print "name is $name\n"; $denovo{$name} = $line; # Quotes not needed. } } print "hash denovo is:\n"; while( my( $key, $value ) = each %denovo ){ print "$key: $value\n"; } __DATA__ no comma comma, in the middle comma at the end, previous line was empty