Mathew Snyder wrote:
It looks like an object is what I want.  Am I correct?  Suppose I need to work
with a bit of data that actually has 11 attributes.  This would be an object of
another type.  However, I need to manipulate pieces of it differently.  So I'm
guessing I would create an object thusly:

sub objectname {
    my %hashOfAttribs {
        attrib1 => undef,
        attrib2 => undef,
        attrib3 => undef
    }
}

I would then create an instance of that object

my $instance = new objectname();

I'm not certain though, how to populate the elements.  would it actually be
my $instance = new objectname(attrib1 => value, attrib2 => value, attrib3 =>
value)?  Or would I create the instance as above and then populate it by some
other means?  For instance
$instance->hashOfAttribs {
    attrib1 => value,
    attrib2 => value,
    attrib3 => value
};

Am I at least on the right track?

Well, sort of. Objects are simply intelligent data structures - structures with
code as well as data that know how to perform operations on themselves. So you
still have to decide on your basic data structure first, and we still need to
know more about what the data is that you're trying to represent before we can
help!

What you've written above is pretty much correct expect that Perl classes (types
of objects) are packages not subroutines. But first lets be sure you really need
to create objects.

Rob



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to