Perl module that simplifies creation of packages?

Perl module that simplifies creation of packages?

am 22.08.2006 16:55:58 von Ignoramus20689

I recall that there is a perl module that simplifies creation of
packages with nice accessors. Like, I could use that module and do
just a few things so that my class would have great get and set
functions, etc, without doing much. I have no recollection of its
name, maybe something::Object or some such.

Any pointers will be appreciated.

thanks

i

Re: Perl module that simplifies creation of packages?

am 22.08.2006 17:16:58 von Christian Winter

Ignoramus20689 wrote:
> I recall that there is a perl module that simplifies creation of
> packages with nice accessors. Like, I could use that module and do
> just a few things so that my class would have great get and set
> functions, etc, without doing much. I have no recollection of its
> name, maybe something::Object or some such.

There are quite a number of those on CPAN, did you try searching
for them yet?
http://search.cpan.org/search?query=Accessor&mode=all
brings quite a list of modules that ease the creation of
accessors.

-Chris

Re: Perl module that simplifies creation of packages?

am 22.08.2006 18:42:19 von Paul Lalli

Ignoramus20689 wrote:
> I recall that there is a perl module that simplifies creation of
> packages with nice accessors. Like, I could use that module and do
> just a few things so that my class would have great get and set
> functions, etc, without doing much. I have no recollection of its
> name, maybe something::Object or some such.

Take a look at Damian Conway's Class::Std module on the CPAN. It does
a lot of this work for you, and creates the Inside-Out classes
recommended by his book, Perl Best Practices.

Paul Lalli

Re: Perl module that simplifies creation of packages?

am 22.08.2006 19:30:52 von mumia.w.18.spam+nospam.usenet

On 08/22/2006 09:55 AM, Ignoramus20689 wrote:
> I recall that there is a perl module that simplifies creation of
> packages with nice accessors. Like, I could use that module and do
> just a few things so that my class would have great get and set
> functions, etc, without doing much. I have no recollection of its
> name, maybe something::Object or some such.
>
> Any pointers will be appreciated.
>
> thanks
>
> i
>

These...

Class::Accessor
Class::Data::Inheritable
Class::Struct

....are some of the options.

Re: Perl module that simplifies creation of packages?

am 22.08.2006 23:38:17 von Ignoramus20689

On Tue, 22 Aug 2006 17:30:52 GMT, Mumia W. wrote:
> On 08/22/2006 09:55 AM, Ignoramus20689 wrote:
>> I recall that there is a perl module that simplifies creation of
>> packages with nice accessors. Like, I could use that module and do
>> just a few things so that my class would have great get and set
>> functions, etc, without doing much. I have no recollection of its
>> name, maybe something::Object or some such.
>>
>> Any pointers will be appreciated.
>>
>> thanks
>>
>> i
>>
>
> These...
>
> Class::Accessor
> Class::Data::Inheritable
> Class::Struct
>
> ...are some of the options.


Thanks guys. Of all, Class::Accessor seems easiest to use,
Class::Struct also is pretty good.

i

Re: Perl module that simplifies creation of packages?

am 23.08.2006 01:06:36 von Big and Blue

Ignoramus20689 wrote:
>
> I recall that there is a perl module that simplifies creation of
> packages with nice accessors. Like, I could use that module and do
> just a few things so that my class would have great get and set
> functions, etc, without doing much. I have no recollection of its
> name, maybe something::Object or some such.

You could write a class that doesn't *need* accessors but defines method
into which you pass data to get things done, so that your class is
self-contained rather than exporting values.

--
Just because I've written it doesn't mean that
either you or I have to believe it.

Re: Perl module that simplifies creation of packages?

am 23.08.2006 02:04:20 von John Bokma

Big and Blue wrote:

> Ignoramus20689 wrote:
> >
>> I recall that there is a perl module that simplifies creation of
>> packages with nice accessors. Like, I could use that module and do
>> just a few things so that my class would have great get and set
>> functions, etc, without doing much. I have no recollection of its
>> name, maybe something::Object or some such.
>
> You could write a class that doesn't *need* accessors but defines
> method
> into which you pass data to get things done, so that your class is
> self-contained rather than exporting values.

One could.

Anyway, to the OP:

http://search.cpan.org/search?query=Class&mode=module

Sounds like "Class::Accessor", which lists under "See Also":

Class::Accessor::Fast

These are some modules which do similar things in different ways
Class::Struct, Class::Methodmaker, Class::Generate, Class::Class,
Class::Contract

HTH,
--
John Experienced Perl programmer: http://castleamber.com/

Perl help, tutorials, and examples: http://johnbokma.com/perl/

Re: Perl module that simplifies creation of packages?

am 26.08.2006 01:11:52 von boyd

In article <44eb1feb$0$10154$9b4e6d93@newsspool1.arcor-online.net>,
Christian Winter wrote:

> Ignoramus20689 wrote:
> > I recall that there is a perl module that simplifies creation of
> > packages with nice accessors. Like, I could use that module and do
> > just a few things so that my class would have great get and set
> > functions, etc, without doing much. I have no recollection of its
> > name, maybe something::Object or some such.
>
> There are quite a number of those on CPAN, did you try searching
> for them yet?
> http://search.cpan.org/search?query=Accessor&mode=all
> brings quite a list of modules that ease the creation of
> accessors.
>
> -Chris

One other module in this series, which I got from the Perl Advent
calendar, is
Class::Accessor::Chained
which I like a lot. It allows one to set the accessor values with one
reference to the object instead of multiple times:

For example:

#!/usr/bin/perl

use strict;
use warnings;
use Carp;
$|++;

package Test;
use base q{Class::Accessor::Chained};
__PACKAGE__->mk_accessors( qw( x y str ) );

sub do_something {
my $self = shift;
print "The values of x and y are: ", $self->x, $self->y, "\n";
print "And the string is: \' " . $self->str . "\' \n";
}

package main_program;

my $obj = Test->new;
# Here is the chained feature:
$obj->x(123.4)
->y(-20.9)
->str("this is an example program")
->do_something;

Boyd

--
boyd