Apologies, that was bad typing in my email. I rearrange the algorithm to make it
easier to read. Here is my exact source and the exact output. Even without the space
there, it still doesn't work!!
Any ideas?
Simon.
sub getEvents
{
my @rows = &getDBTable($tbl_events);
my @colDefs = ("");
@colDefs = split(",",substr($rows[0], index($rows[0],":")+1));
my $rowCount = -1;
my @rowCols;
foreach $row (@rows)
{
if ($rowCount > -1)
{
my %tempCols = &getCols($row, @colDefs);
foreach $key (keys %tempCols)
{
print "WORKS: $key $tempCols{$key}<br>\n";
}
$rowCols[$rowCount] = %tempCols;
}
my %event = $rowCols[$rowCount];
foreach $key (keys %event)
{
print "DOESN'T WORK: $key $event{$key}<br>\n";
}
$rowCount = $rowCount + 1;
}
return @rowCols;
}
DOESN'T WORK:
WORKS: description Rehearsal
WORKS: event_time 18:30
WORKS: event_id 1
WORKS: event_date 07-09-2002
DOESN'T WORK: 4/8
WORKS: description Church Service
WORKS: event_time 11:00
WORKS: event_id 2
WORKS: event_date 08-09-2002
DOESN'T WORK: 4/8
WORKS: description Rehearsal
WORKS: event_time 18:30
WORKS: event_id 3
WORKS: event_date 14-09-2002
DOESN'T WORK: 4/8
WORKS: description Church Service
WORKS: event_time 11:00
WORKS: event_id 3
WORKS: event_date 15-09-2002
DOESN'T WORK: 4/8
Regards
Simon
Nikola Janceski
<nikola_janceski@su To: Simon Tomlinson/DMGGM/DMG
UK/DeuBa@DMG UK, [EMAIL PROTECTED]
mmithq.com> cc:
Subject: RE: Array of Hashes
18/09/2002 14:11
you have a space that shouldn't be there:
> print "THIS DOESN'T WORK: $key $newHash {$key}\n";
^
should be:
print "THIS DOESN'T WORK: $key $newHash{$key}\n";
> -----Original Message-----
> From: Simon Tomlinson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 18, 2002 9:06 AM
> To: [EMAIL PROTECTED]
> Subject: Array of Hashes
>
>
> Hi
>
> I want to put a hash into each element of an array. I do it
> like the following bit of code. When I iterate round my hash
> before putting it in the array of the hash values/keys are
> there. However, when I iterate through the hash after
> putting it in the array all i get is '4/8' as the ouput.
>
> I am sure this is very simple and I'm doing something stupid.
> Does anyone have any ideas?
>
> Thanks in advance,
> Simon.
>
> my @array
> my $count = 0;
> my $maxCount = 4;
>
> while $count < $maxCount
> {
> my %myHash = &getHash;
>
> foreach $key (keys %myHash )
> {
> print "THIS WORKS: $key $myHash{$key}\n";
> }
>
> # Now assign the hash to my array
> $array[$count] = %myHash;
>
> my %newHash = $array[$count];
> foreach $key (keys %newHash )
> {
> print "THIS DOESN'T WORK: $key $newHash {$key}\n";
> }
> }
>
>
> --
>
> This e-mail may contain confidential and/or privileged
> information. If you are not the intended recipient (or have
> received this e-mail in error) please notify the sender
> immediately and destroy this e-mail. Any unauthorized
> copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorized copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]