YEsterday i posted a reference problem I have solved myself :) But now I'm stuck on another little problem:
use strict; use Tie::IxHash; my %login; { tie( my %csv, 'Tie::IxHash', 'one' => undef, 'two' => undef, 'three' => undef, 'four' => undef, 'five' => undef, ); $csv{one} = "11"; $csv{two} = "12"; $csv{three} = "13"; $csv{four} = "14"; $csv{five} = "15"; $login{1} = \%csv; } { tie( my %csv, 'Tie::IxHash', 'one' => undef, 'two' => undef, 'three' => undef, 'four' => undef, 'five' => undef, ); $csv{one} = "11"; $csv{two} = "12"; $csv{three} = "23"; $csv{five} = "25"; $login{2} = \%csv; }{ tie( my %csv, 'Tie::IxHash', 'one' => undef, 'two' => undef, 'three' => undef, 'four' => undef, 'five' => undef, ); $csv{one} = "31"; $csv{three} = "23"; $csv{four} = "34"; $csv{five} = "25"; my $match = "2"; my %union; while (my ($k,$v) = each %login) { if ($k eq $match) { print "MATCH\n"; while ( my ($k, $v) = each %$v ) { $union{$k} = $v; } while ( my ($k, $v) = each %csv ) { $union{$k} = $v; } print map{$_ ."=". $union{$_} ."\n"} keys %union; } else { print "NO MATCH\n"; while ( my ($k, $v) = each %$v ) { print $k ."=". $v."\n"; } } } }
This demo code can be run... But as you can see the union doesn't work! It will show that there isn't a union of the 2 hashes but only a print of the last hash.
If I make a union that way in another small script, it works perfect. But when I do it in this bigger example it doens't work anymore. Suggestions?

--
My opinions may have changed,
but not the fact that I am right


In reply to Union of 2 hashes don't work. by toadi

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.