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