use Path::Class; use Data::Dumper; my $dir = dir("C:\\temp\\"); my $file = $dir->file("hashinput.txt"); my $file_handle = $file->openr(); my %slotHash = (); while (my $line = $file_handle->getline()){ if (index($line, "Press", 0) == -1) { $delimiter = quotemeta("^"); my @values = split(/$delimiter/, $line); %slothash = (slot => @values[0] => [type => @values[1]]); } } print Dumper(%slothash);