Your have a typo in the example given below ... you are missing a '$' in front
of members in the main package
        for($i=0; $i<10; $i++){members->[$i] = $i;}
but should be
                for($i=0; $i<10; $i++){$members->[$i] = $i;}
                
if you ran your script with 'use strict' the compiler would have told you the
mistake
other than that your script seems to work fine.

On Fri, Aug 31, 2001 at 10:50:09AM -0500, Kaleb Murphy shaped the electrons to read:
> 
> -----Original Message-----
> From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 31, 2001 10:30 AM
> To: Kaleb Murphy
> Cc: [EMAIL PROTECTED]
> Subject: Re: Objects
> 
> 
> On Fri, 31 Aug 2001, Kaleb Murphy wrote:
> 
> > Could someone give me an example of an object that has an array as a data
> > member?  Maybe a simple object and a simple method to return that array.
> 
> What have you tried so far?
> 
> -- Brett
>                                           http://www.chapelperilous.net/
> ------------------------------------------------------------------------
> f u cn rd ths, itn tyg h myxbl cd.
> 
> 
> This is one of my attempts to make this work.  The method that returns the
> scalar works.  That method that returns the pointer to the array, doesn't
> work.
> 
> sub test
> {
> 
>       package person;
>       sub new
>       {
>               my $package = shift;
>               my %args = @_;
>               my $self = \%args;
>               bless $self, $package;
>               $self;
>       }
> 
>       package person;
>       sub get_name
>       {
>               my $self = shift;
>               $self->{"name"};
>       }
> 
>       package person;
>       sub get_array
>       {
>               my $self = shift;
>               $self->{"array"};
>       }
> 
> }
> 
> 
>       $sname = "CblInfo";
>       for($i=0; $i<10; $i++){members->[$i] = $i;}
>       $a = new person(name => $sname,array => $members);
>       $name = "blah";
> 
>       $name = $a->get_name;
>       $mem = $a->get_array;
> 
>       print "$name\n";
>       for ($i = 0; $i < 10; $i++)
>       {
>       print "$mem->[$i]\n";
>       }
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to