[Phoenix-pm] Hash of Arrays of Objects

Frooninckx Craig - cfroon Craig.Frooninckx at acxiom.com
Mon Aug 2 10:02:02 CDT 2004

I'm new to objects in Perl and I'm trying to create an object call Task,
that I load into a Hash of Arrays based on the due date attribute of the
object.  Everything appears fine until I start to step through the
Hash/Array to call the print method of the loaded object.  It appears not to
work, but the print statements that I put in show the same type and
reference as was created at the beginning.  I'm assuming that there is
something simple about this that I've overlooked and/or don't understand.
Any insight and suggestions would be appreciated.




use lib "lib";

use Task;


my %todo;


my $task1 = new Task( something => "me", desc => "This is my first task" );
print $task1->print(), "\n"; print STDERR "\$task1: [$task1]\n"; push @{
$todo{ $task1->tsort() } }, $task1; my $task2 = new Task( due =>
"2004-12-18", desc => "Second Task", type => "work" ); #print
$task2->print(), "\n"; push @{ $todo{ $task2->tsort() } }, $task2;


foreach my $key ( sort keys %todo ) {

      print STDERR "\$key: [$key]\n";

      foreach my $obj ( @{ $todo{ $key } } ) {

            print STDERR "\$obj: [$obj]\n";

            $obj->print(), "\n";








Pending                       Home This is my first task

$task1: [Task=HASH(0x8152410)]

$key: []

$obj: [Task=HASH(0x8152410)]

$key: [1103353200]

$obj: [Task=HASH(0x819731c)]



The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/phoenix-pm/attachments/20040802/bbdb9336/attachment.htm

More information about the Phoenix-pm mailing list