http://qs1969.pair.com?node_id=487521

Bugorr has asked for the wisdom of the Perl Monks concerning the following question:

Thank you everyone for your replys - they were very helpfull, but did not solve my problem!!!
Here's a little more detailed explanation:

I need to read a file (line by line of course).
Line looks like that "subject^email^timestamp"

After file is read I need to do Insertion into database. Now, subjects could be the same and I decided to create this datastructure:
%subjects{$subject}{%hash => email, timestamp} (hope it's clear so far)
%subjects is hash, which has "subject" as a key
$subject is array, which holds hashes or emails and times

So, I created this code:
my %subjects; foreach my $subm(@subm){ ($subject, $email, $time) = split(/^/, $subm); my %info; $info{email} = $email; $info{time} = $time; if(! exists $subjects{$subject}){ print "Key DOES NOT exist\n"; $subjects{$subject} = []; }else{ print "KEY DO EXIST\n"; } push @{$subjects{$subject}}, %info; }

I have this code to check that everything is correct:
foreach my $key (sort (keys %subjects)){ print "\n\nKEY = $key"; my @ar = @{subjects{$key}}; my $size = @ar; print "\nSize of Array = $size"; }

Unfortunately, Size gives me size =1 , which is not true. Please tell me if I am doing something wrong....

Thank you very much!!!

code tags by holli