my (@firms); while (defined( my $line = ) ){ chomp $line; my (%hash); my ($type, $location1, $location2, $label) = split ',', $line, 12; $hash{type} = $type; $hash{label} = $label; push @firms, \%hash; } #### @fields=qw(name64 label location1 subnet support_radius); for(my $i=0; $i<=$#firms; $i++) { $firms[$i]->{subnet} /= 32; $upload .= sprintf "%s\n", join ',', @{$firms[$i]}{@fields}; }