in reply to Re^3: read hash table from a subroutine or retrieve previously stored hash table from a file
in thread read hash table from a subroutine or retrieve previously stored hash table from a file

well, im saving array_cvs contents in hash table. What's is the other way of representation referring value. Please let know.

  • Comment on Re^4: read hash table from a subroutine or retrieve previously stored hash table from a file

Replies are listed 'Best First'.
Re^5: read hash table from a subroutine or retrieve previously stored hash table from a file
by marinersk (Priest) on Nov 20, 2013 at 09:01 UTC
    Your expected output does not show arrays of values. It shows single scalar values. So your question does not make sense to me. I must be missing something.

    Let me analyze how the code aligns with your stated goals in more detail -- on the surface it simply seemed like you wanted scalar but were storing arrays.

      Okay, finally got some time to look at this.

      The full explanation is hidden behind the <readmore>tag.

      Summary: Making the following changes:

      chomp $line; $line =~ s/\s*\z//; my @array_CSV = split /,/, $line; my ($key_CSV, $value_CSV, @extraStuff) = @array_CSV; if ($hash{$key_CSV}) { warn "Duplicate key '$key_CSV'"; }; $hash{$key_CSV} = $value_CSV;

      Produces:

      C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>perl testhash2.pl test.c +sv Number of Pins: 6 Stored 6 list of pins in test_RX.csv file. AVD0 => Group4 SIDDQ => Group7 C_WREN => Group1 CAL_CLK => Group1 REF_RATE[9:0] => Group3 RX_IBIAS_2_25U[4:0] => Group3

      Note: The @extraStuffis superfluous, left in for example purposes.

      So, unless I'm missing something, it looks like all you had to do was store the value instead of the array reference.

      Holler if this isn't what you were looking for.