sub mainCSV { open (my $inputfile1, '<', "$inputfile") or die "Unable to open $inputfile1: $!"; my %hash; while( my $line = <$inputfile1> ) { $line =~ s/\s*\z//; my @arrayfile1 = split /,/, $line; my $keyfile1 = shift @arrayfile1; $hash{$keyfile1} = \@arrayfile1; } print %hash; close $inputfile1; }