Re: Perl module that simplifies creation of packages?
- From: boyd <tbmoore9@xxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 23:11:52 GMT
In article <44eb1feb$0$10154$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Christian Winter <thepoet_nospam@xxxxxxxx> 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
.
- References:
- Perl module that simplifies creation of packages?
- From: Ignoramus20689
- Re: Perl module that simplifies creation of packages?
- From: Christian Winter
- Perl module that simplifies creation of packages?
- Prev by Date: Re: calling methods on deserialized objects
- Next by Date: Re: calling methods on deserialized objects
- Previous by thread: Re: Perl module that simplifies creation of packages?
- Next by thread: Re: Perl module that simplifies creation of packages?
- Index(es):
Relevant Pages
|