Hey there! Currently, I'm having troubles with Perl printing the memory location of a hash when I feel that I haven't given it sufficient cause to do so. This is a word processing tool that I'm making for myself to help in the study of foreign languages. I'm reading in English words and their foreign (in my case, German) equivalent, and storing them in a hash. When one iterates over the hash, however, Perl decides that I'm telling it to print out the hashes memory location as well as all the elements of the hash I have purposefully put in there. It's interesting to note that the hashes memory location does not receive a 'tag' from the hash_processor subroutine. Any help would be greatly appreciated.

sub add_words::main () { my %words = {}; my $english; my $foreign; until ('1' == '0') { print "Enter English: "; chomp($english = <STDIN>); print "Enter German: "; chomp($foreign = <STDIN>); if (($english && $foreign) eq '-1') { last; } ($english, $foreign) = &hash_processor::function($english, $foreign +, '0'); $words{$english} = $foreign; } foreach my $word (sort keys %words) { # First output is description of hash's mem location, and I DON'T K +NOW WHY. print "$word ==> $words{$word}\n"; } } sub hash_processor::function () { my ($english, $foreign, $process) = @_; if ($process == '0') { $english = "$english" . "$hash_processor::tag_count"; $foreign = "$foreign" . "$hash_processor::tag_count"; } $hash_processor::tag_count++; return ($english, $foreign); }

Output is something like:

HASH(0x950c5e6) ==> word ==> Wort two words ==> zwei Woerter etc. ==> usw.

In reply to Hash Printing reveals Hash Memory Location by perlStuck

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.