in reply to Re^2: 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

This line:

 $hash{$key_CSV} = \@array_CSV;

Is causing your most immediate problem. You are storing the reference to the array in your hash elements. So when you print out the hash elements, you are getting a reference to an array.

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

Replies are listed 'Best First'.
Re^4: read hash table from a subroutine or retrieve previously stored hash table from a file
by waytoperl (Beadle) on Nov 20, 2013 at 02:09 UTC

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

      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.