%locations = ( "location1" => { "users" => { "Login1" => "Name1", "Login2" => "Name2", ... ], "ip" => "127.0.0.1", "otherinfo" => [ "info", "info2","infoblah"...] }, "location2" => { "users" => { "Login1" => "Name1", "Login2" => "Name2", ... ], "ip" => "127.0.0.1", "otherinfo" => [ "info", "info2","infoblah"...] }, ... ) #### use strict; #input format for testing my $string = 'fooLogin,barName,bazLocation,Info,Info2,Infoblah'; my %locations; #split it up on commas from our example. #you would need to decide what to do with the rest. my @temp_info = split /,/,$string; $locations{$temp_info[2]}->{users}->{$temp_info[0]} = $temp_info[1]; $locations{$temp_info[2]}->{otherinfo} = [@temp_info[3..$#temp_info]];