Ive stumbled upon a problem that im having a tough time finding a solution on, and thats storing key/value pair in a hash. I have a standard $text variable that im appending text to. I double checked and when i print out $text it does indeed store the correct information. However, when try this : %descHash = (%descHash,$file, $text); and then try to print out the contents of %descHash, i get the $file being stored correctly, but the $text comes out with a number between 1 and 4.

I must note that the variable $text changes throughout the program,(not through the hash though) so im not sure if the hash is storing $text as a reference or the actual value is being stored, but it dosnt make sense to me. If anyone knows whats going on, please help! here is my output:
Key = oleochemicals-index.html Value = 1 Key = pilot-index.html Value += 1 Key = news.html Value = 4 Key = deodorizing.html Value = 1 Key = +profile.html Value = 2 Key = refining.html Value = 1 Key = products.h +tml Value = 3 Key = profile-index.html Value = 2 Key = extraction-ind +ex.html Value = 1 Key = refining-index.html Value = 1 Key = index.htm +l Value = 2 Key = products-index.html Value = 3 Key = preparation-ind +ex.html Value = 1 Key = dryer-index.html

In reply to Question about hashes by wizard341

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.