Click here to get back home

Perl module that simplifies creation of packages?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    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
Perl module that simplifies creation of packages? Ignoramus20689 08-22-2006
Get Chitika Premium
Posted by Ignoramus20689 on August 22, 2006, 10:55 am
Please log in for more thread options


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


Posted by Christian Winter on August 22, 2006, 11:16 am
Please log in for more thread options


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

Posted by boyd on August 25, 2006, 7:11 pm
Please log in for more thread options



> 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;
__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

Posted by Paul Lalli on August 22, 2006, 12:42 pm
Please log in for more thread options


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


Posted by Mumia W. on August 22, 2006, 1:30 pm
Please log in for more thread options


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.


Similar ThreadsPosted
web based bibliography creation by users January 1, 2005, 5:18 pm
Modules with several packages October 16, 2005, 10:50 am
DBI and DBI::Oracle packages configuration July 22, 2004, 8:55 am
multiple packages (modules) in the same file May 2, 2005, 3:53 pm
Problems with forked packages and CPAN March 30, 2006, 1:53 pm
Perl Module using XS May 3, 2008, 5:09 pm
Perl module PDF::API2 July 11, 2004, 5:35 am
Perl GD::Graph module: bug? August 3, 2004, 8:42 pm
Installing DBI module for Perl 5.8.4 October 4, 2005, 6:26 am
Problem with Net::SSH::Perl module December 22, 2004, 12:38 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap