Putting/accessing an object from an array - help! 
Author Message
 Putting/accessing an object from an array - help!

Here's the problem:

#!/usr/local/bin/perl -w

package Person;
use strict;

sub new
{
        my $proto = shift();
        my $class = ref($proto) || $proto;
        my $self = {};
        $self->{NAME} = undef;
        $self->{AGE} = undef;
        $self->{PEERS} = [];
        bless($self, $class);
        return $self;

Quote:
}

sub name
{
        my $self = shift;

        return $self->{NAME};

Quote:
}

sub age
{
        my $self = shift;

        return $self->{AGE};

Quote:
}

sub peers
{
        my $self = shift;


Quote:
}

1;  # package Person;

package main;
use strict;


my $me = Person->new();
$me->name("Asfand Yar");
$me->age(22);
$me->peers("Naz", "Amjad");



        printf("%s is %d years old.\n", $i->name(), $i->age());
        print("His peers are: ", join(", ", $i->peers()), "\n");

Quote:
}

And sorry for being so ignorant.

Asfand Yar

asfand at email.com



Wed, 07 Sep 2005 11:29:43 GMT  
 Putting/accessing an object from an array - help!



Quote:
> Here's the problem:

What is your question?


Wed, 07 Sep 2005 15:15:27 GMT  
 Putting/accessing an object from an array - help!

Quote:

> Here's the problem:
...


()---------------^^


...

Quote:
> Asfand Yar

...

--
Bob Walton



Wed, 07 Sep 2005 16:12:07 GMT  
 Putting/accessing an object from an array - help!

Quote:


>> Here's the problem:

> ....


> ()---------------^^

> The [] puts a reference to an empty array in the first element of

> ....

>> Asfand Yar

> ....

Many thanks.


Wed, 07 Sep 2005 17:21:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP: putting an @array into an %array???

2. Can I put an object in an object?

3. Accessing Objects in an array

4. help putting each page of report in to its own array

5. Help Putting data from an file that Perl reads into a JavaScript array

6. Need Help with putting Hashes in a two-dimensional array

7. Accessing objects within objects

8. putting arrays in arrays!?!?

9. hash of objects vs array of objects

10. Help: An array of objects with a class

11. Putting a hash in an object/method?

 

 
Powered by phpBB® Forum Software