use strict; use warnings; use Data::Dumper; my %db_hash; while () { chomp; my ($path, $start, $end, $delay) = split /\s+/, $_; # Get index for this path (if undefined, set it to 1) my $index = ++$db_hash{$path}{'index'}; $db_hash{$path}{$index}{START} = $start; $db_hash{$path}{$index}{END} = $end; $db_hash{$path}{$index}{DELAY} = $delay; } printf "Contents of db_hash => %s\n", Dumper(\%db_hash); __DATA__ my_path /path/3434/some_txt wodo -445 your_path /path/3434/some_txt wodo_modo 41 my_path2 /path/232/wge45 wodo_modo 240 my_path /t43/annow23x /a/b/c/43 NA