For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > October 2006 > A doubt in using Class::Struct









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author A doubt in using Class::Struct
None

2006-10-05, 6:58 pm

Hello,

I am trying to use Class::Struct, for creating a structure as follows:

package Classes;
use Class::Struct;
struct(messages => '@');

$msg = new Classes;
push(@abc, "HELLO");
push(@abc, "WORLD");
push(@abc, "BYE");
$msg->messages(@abc);

@xyz = @{$msg->messages};
foreach $elem(@xyz)
{
print $elem ."\n";
}

This gives the following error on compilation:

Too many args to messages at (eval 1) line 17
Classes::messages('Classes=ARRAY(0x81030
84)', 'HELLO', 'WORLD',
'BYE')

Also, if I remove the third element of the array, the program compiles,
but I get the following output:
WORLD

The element "HELLO is not displayed.
Can anyone help me with this or let me know what the problem is?

Thanks,
Avi.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com