I think somewhere you must have assigned the result of scalar %hash instead of \%hash. I have taken the liberty of restructuring your code slightly to illuminate the reference I believe you are trying to make:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); {my %h = qw(1 2 3 4); say "What happens when you apply scalar to a hash is this: ", scalar + %h; } {my $h1 = {'ArcelorMittal' => '54/128','Aperam' => '28/64','Unilever' + => '246/512','Ahold' => '19/32','Akzo' => '33/64','PostNL' => '141/2 +56','DSM' => '104/256','Philips' => '135/256','TNT' => '219/512','Ran +dstad' => '147/256','Royal' => '159/256','Wolters' => '238/512','SBM' + => '212/512','Reed' => '153/256','ASML' => '46/128','Heineken' => '1 +20/256','Boskalis' => '67/128','Aegon' => '11/16','Corio' => '74/128' +,'Fugro' => '113/256','ING' => '57/128','KPN' => '129/256','TomTom' = +> '228/512' }; my $h2 = {'Aegon2' => ['4,109','4,280','4,09','4,28' ],'Aegon7' => +['4,100','3,996','3,98','4,11' ],'Aegon3' => ['4,045','4,107','4,03' +,'4,13' ],'Aegon14' => [ '4,175', '4,249', '4,18', '4,28' ],'Aegon +1' => ['4,300','4,318','4,29','4,38' ],'Aegon4' => ['4,087','4,067', +'4,06','4,12' ],'Aegon13' => [ '4,209', '4,249', '4,16', '4,28' ], +'Aegon10' => [ '4,111', '4,169', '4,10', '4,20' ],'Aegon5' => ['4,0 +61','4,100','4,05','4,12' ],'Aegon9' => ['4,127','4,151','4,12','4,1 +8' ],'Aegon11' => [ '4,180', '4,103', '4,07', '4,19' ],'Aegon12' = +> [ '4,286', '4,198', '4,16', '4,30' ],'Aegon6' => ['4,009','4,083' +,'4,00','4,12' ],'Aegon8' => ['4,147','4,122','4,08','4,16' ]}; my $a; push @$a, $h2->{"Aegon$_"} for 1..14; $h1->{Aegon} = $a; # Please do not use scalar() here pp($h1); say "Aegon,2,1 = ", $h1->{Aegon}[2][1]; }

Produces:

{ Aegon => [ ["4,300", "4,318", "4,29", "4,38"], ["4,109", "4,280", "4,09", "4,28"], ["4,045", "4,107", "4,03", "4,13"], ["4,087", "4,067", "4,06", "4,12"], ["4,061", "4,100", "4,05", "4,12"], ["4,009", "4,083", "4,00", "4,12"], ["4,100", "3,996", "3,98", "4,11"], ["4,147", "4,122", "4,08", "4,16"], ["4,127", "4,151", "4,12", "4,18"], ["4,111", "4,169", "4,10", "4,20"], ["4,180", "4,103", "4,07", "4,19"], ["4,286", "4,198", "4,16", "4,30"], ["4,209", "4,249", "4,16", "4,28"], ["4,175", "4,249", "4,18", "4,28"], ], Ahold => "19/32", Akzo => "33/64", Aperam => "28/64", ArcelorMittal => "54/128", ASML => "46/128", Boskalis => "67/128", Corio => "74/128", DSM => "104/256", Fugro => "113/256", Heineken => "120/256", ING => "57/128", KPN => "129/256", Philips => "135/256", PostNL => "141/256", Randstad => "147/256", Reed => "153/256", Royal => "159/256", SBM => "212/512", TNT => "219/512", TomTom => "228/512", Unilever => "246/512", Wolters => "238/512", } What happens when you apply scalar to a hash is this: 2/8 Aegon,2,1 = 4,107

In reply to Re: perl strange hash value by philiprbrenan
in thread perl strange hash value by robertw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.