while (){ #remove spaces from the beginning or the end of the file s/^\s+|\s+$//g; # splits the files based on columns based on space and limit the amount split by 4 my ($col1,$col2,$col3) = split /\s+/,$_,4; #checks to see if the word name is matched to get the variable next over which would be the actual name , then put it in variable $name if ($col1 eq 'name'){ $name = $col2; #checks to see if the word device is matched to get the variable next over which would be the actual type, then next over is another attribute(not on the example) } elsif ($col1 eq 'device') { ##Here the push name, device type and other variable into a hash push @{$hash{$name}},$col2, $col3; } else { # skip line } } close IN;