my @AoA; my %HoAoA; my %HoAoH; while( my $line = ){ chomp $line; my @fields = split( /\s+\s+/, $line ); # Add an array ref (containing the data in @fields) onto the @AoA push( @AoA, [ @fields ] ); # Add an array ref (containing the last 2 elements of @fields) # onto the %HoAoA. The key in the %HoAoA is $fields[0], and # the value is an array ref. '@fields[ 1, 2 ]' is an array # slice and is shorthand for ( $fields[1], $fields[2] ) push( @{ $HoAoA{$fields[0]} }, [ @fields[ 1, 2 ] ] ); # Add a hash ref onto the %HoAoH. The key in the %HoAoH is # $fields[0], and the value is an array ref. The array # contains one or more hash refs. Each hash ref # contains the 'email' and 'result' keys. push( @{ $HoAoH{$fields[0]} }, { email => $fields[1], result => $fields[2] } ); } #### $VAR1 = [ [ 'susan', 'anus@delta.co.th', 'cannot find your hostname' ], [ 'jennifer', 'r_curran@ntnu.no', 'cannot find your hostname' ], [ 'jennifer', 'jones@bol.net.in', 'cannot find your hostname' ], [ 'jennifer', 'millionairemaker@freshcornam.com', 'cannot find your hostname' ], [ 'tim', 'millionairemaker@freshcornam.com', 'cannot find your hostname' ], [ 'jennifer', 'cmayer@kareltek.fi', 'cannot find your hostname' ], [ 'jack', 'ictiplo@tiplo.com.tw', 'cannot find your hostname' ], [ 'russ', 'orders@koss.com', 'Host not found' ], [ 'clara', 'Sandra@camrpc.com', 'Host not found' ], [ 'jennifer', 'Warranty@onlogixx.com', 'cannot find your hostname' ], [ 'employment', 'elitemate@rllformat.com', 'cannot find your hostname' ], [ 'jack', 'JHuffman@pulsetech.net', 'cannot find your hostname' ], [ 'clara', 'Sandra@camrpc.com', 'Host not found' ], [ 'susan', 'linda@kepro.com.tw', 'cannot find your hostname' ], [ 'jobs', 'kwillis@cors.com', 'Host not found' ], [ 'employment', 'LifeShopDirect@freshcornam.com', 'Host not found' ] ]; #### $VAR1 = { 'jack' => [ [ 'ictiplo@tiplo.com.tw', 'cannot find your hostname' ], [ 'JHuffman@pulsetech.net', 'cannot find your hostname' ] ], 'jobs' => [ [ 'kwillis@cors.com', 'Host not found' ] ], 'jennifer' => [ [ 'r_curran@ntnu.no', 'cannot find your hostname' ], [ 'jones@bol.net.in', 'cannot find your hostname' ], [ 'millionairemaker@freshcornam.com', 'cannot find your hostname' ], [ 'cmayer@kareltek.fi', 'cannot find your hostname' ], [ 'Warranty@onlogixx.com', 'cannot find your hostname' ] ], 'tim' => [ [ 'millionairemaker@freshcornam.com', 'cannot find your hostname' ] ], 'susan' => [ [ 'anus@delta.co.th', 'cannot find your hostname' ], [ 'linda@kepro.com.tw', 'cannot find your hostname' ] ], 'russ' => [ [ 'orders@koss.com', 'Host not found' ] ], 'employment' => [ [ 'elitemate@rllformat.com', 'cannot find your hostname' ], [ 'LifeShopDirect@freshcornam.com', 'Host not found' ] ], 'clara' => [ [ 'Sandra@camrpc.com', 'Host not found' ], [ 'Sandra@camrpc.com', 'Host not found' ] ] }; #### $VAR1 = { 'jack' => [ { 'result' => 'cannot find your hostname', 'email' => 'ictiplo@tiplo.com.tw' }, { 'result' => 'cannot find your hostname', 'email' => 'JHuffman@pulsetech.net' } ], 'jobs' => [ { 'result' => 'Host not found', 'email' => 'kwillis@cors.com' } ], 'jennifer' => [ { 'result' => 'cannot find your hostname', 'email' => 'r_curran@ntnu.no' }, { 'result' => 'cannot find your hostname', 'email' => 'jones@bol.net.in' }, { 'result' => 'cannot find your hostname', 'email' => 'millionairemaker@freshcornam.com' }, { 'result' => 'cannot find your hostname', 'email' => 'cmayer@kareltek.fi' }, { 'result' => 'cannot find your hostname', 'email' => 'Warranty@onlogixx.com' } ], 'tim' => [ { 'result' => 'cannot find your hostname', 'email' => 'millionairemaker@freshcornam.com' } ], 'susan' => [ { 'result' => 'cannot find your hostname', 'email' => 'anus@delta.co.th' }, { 'result' => 'cannot find your hostname', 'email' => 'linda@kepro.com.tw' } ], 'russ' => [ { 'result' => 'Host not found', 'email' => 'orders@koss.com' } ], 'employment' => [ { 'result' => 'cannot find your hostname', 'email' => 'elitemate@rllformat.com' }, { 'result' => 'Host not found', 'email' => 'LifeShopDirect@freshcornam.com' } ], 'clara' => [ { 'result' => 'Host not found', 'email' => 'Sandra@camrpc.com' }, { 'result' => 'Host not found', 'email' => 'Sandra@camrpc.com' } ] };