use strict;
use Tie::IxHash;
tie( my %csv, 'Tie::IxHash',
'one' => undef,
'two' => undef,
'three' => undef,
'four' => undef,
'five' => undef,
);
my %login;
{
my %dummy = %csv;
$dummy{one} = "11";
$dummy{two} = "12";
$dummy{three} = "13";
$dummy{four} = "14";
$dummy{five} = "15";
$login{1} = \%dummy;
}
{
my %dummy = %csv;
$dummy{one} = "11";
$dummy{two} = "12";
$dummy{three} = "23";
$dummy{four} = "14";
$dummy{five} = "25";
$login{2} = \%dummy;
}
{
my %dummy = %csv;
$dummy{one} = "31";
$dummy{two} = "12";
$dummy{three} = "23";
$dummy{four} = "34";
$dummy{five} = "25";
$login{2} = \%dummy;
while (my ($k,$v) = each %login) {
print "NEW\n";
while ( my ($k, $v) = each %{dummy} ) { print $k." =". $v ."\n";
+ }
}
}
I want the output to be:
NEW
one =11
five =12
three =13
two =13
four =14
five =15
NEW
one =31
five =25
three =23
two =12
four =34
five =25
Problem is that i want to loop login and if the key of login matches with one before it should be a hash union and when it doesn't matches just print the hash it contains.
If you need some more info pm me... I'm going to try to find the solution too :p But have been trying many options and I'm a bit stuck :(
--
My opinions may have changed,
but not the fact that I am right
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.