Click here to get back home

declare structure

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
declare structure Rose 03-09-2008
Posted by Rose on March 9, 2008, 3:36 am
Please log in for more thread options

One day i found some codes by others write like this way (i can't remember
the exact codes):

a[0]->idx = 1; # or => 1?
a[0]->name = "foo";
a[0]->loc = "earth";

I doubt it's OO programing but Perl in 21 Days told me that may be another
story. I'm not using associative array because i need all 3 or more
information later and associative array may not provide convenient way for
me to retrieve the information. Could anybody shed some light on what topic
I should refer to ?



Posted by Ben Morrow on March 9, 2008, 5:09 am
Please log in for more thread options

> >
> > a[0]->idx = 1; # or => 1?
> > a[0]->name = "foo";
> > a[0]->loc = "earth";
>
> It was probably more like
>
> $a[0]->=1;
>
> It could also have been (unlikely)
>
> $a[0]->idx(1);

It *could* also have been

$a[0]->idx = 1;

using something like

{
package My;

my $idx;

sub idx : lvalue method { $idx }
}

my @a = bless [], 'My';

This construction is considered a bad idea nowadays, as it's very hard to
insert a proper 'set' method later.

Ben


Similar ThreadsPosted
FAQ 7.8 How do I declare/create a structure? March 6, 2005, 6:03 pm
FAQ 7.8 How do I declare/create a structure? May 10, 2005, 5:03 am
FAQ 7.8 How do I declare/create a structure? July 25, 2005, 10:03 pm
FAQ 7.8 How do I declare/create a structure? September 20, 2005, 4:03 pm
FAQ 7.8 How do I declare/create a structure? November 1, 2005, 11:03 pm
FAQ 7.8 How do I declare/create a structure? December 10, 2005, 11:03 am
FAQ 7.8 How do I declare/create a structure? December 20, 2005, 11:03 pm
FAQ 7.8 How do I declare/create a structure? November 11, 2006, 3:03 am
FAQ 7.8 How do I declare/create a structure? March 2, 2007, 9:03 am
FAQ 7.8 How do I declare/create a structure? May 17, 2007, 3:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap