sub mainCSV { # Open the CSV input file open (my $infile_CSV1, '<', "$infile_CSV") or die "Unable to open $infile_CSV: $!\n"; my %hash = (); my $hash_ref = \%hash; while (my $line = <$infile_CSV1>) { chomp; $line =~ s/\s*\z//; my @array_CSV = split /,/, $line; my $key_CSV = shift @array_CSV; push @{ $hash_ref->{$key_CSV} }, $_ foreach @array_CSV; print Data::Dumper->Dump([ \@array_CSV, $hash_ref], ["array_CSV", "hash_ref"] ); } # Explicit scalar context my $size = scalar keys %hash; }