How to Install and Uninstall perl-Class-Accessor Package on openSuSE Tumbleweed
Last updated: November 07,2024
1. Install "perl-Class-Accessor" package
Learn how to install perl-Class-Accessor on openSuSE Tumbleweed
$
sudo zypper refresh
Copied
$
sudo zypper install
perl-Class-Accessor
Copied
2. Uninstall "perl-Class-Accessor" package
Please follow the step by step instructions below to uninstall perl-Class-Accessor on openSuSE Tumbleweed:
$
sudo zypper remove
perl-Class-Accessor
Copied
3. Information about the perl-Class-Accessor package on openSuSE Tumbleweed
Information for package perl-Class-Accessor:
--------------------------------------------
Repository : openSUSE-Tumbleweed-Oss
Name : perl-Class-Accessor
Version : 0.51-1.24
Arch : noarch
Vendor : openSUSE
Installed Size : 40.7 KiB
Installed : No
Status : not installed
Source package : perl-Class-Accessor-0.51-1.24.src
Upstream URL : http://search.cpan.org/dist/Class-Accessor/
Summary : Automated accessor generation
Description :
This module automagically generates accessors/mutators for your class.
Most of the time, writing accessors is an exercise in cutting and pasting.
You usually wind up with a series of methods like this:
sub name {
my $self = shift;
if(@_) {
$self->{name} = $_[0];
}
return $self->{name};
}
sub salary {
my $self = shift;
if(@_) {
$self->{salary} = $_[0];
}
return $self->{salary};
}
One for each piece of data in your object. While some will be unique, doing
value checks and special storage tricks, most will simply be exercises in
repetition. Not only is it Bad Style to have a bunch of repetitious code,
but it's also simply not lazy, which is the real tragedy.
If you make your module a subclass of Class::Accessor and declare your
accessor fields with mk_accessors() then you'll find yourself with a set of
automatically generated accessors which can even be customized!
The basic set up is very simple:
package Foo;
use base qw(Class::Accessor);
Foo->mk_accessors( qw(far bar car) );
Done. Foo now has simple far(), bar() and car() accessors defined.
Alternatively, if you want to follow Damian's _best practice_ guidelines
you can use:
package Foo;
use base qw(Class::Accessor);
Foo->follow_best_practice;
Foo->mk_accessors( qw(far bar car) );
*Note:* you must call 'follow_best_practice' before calling 'mk_accessors'.
--------------------------------------------
Repository : openSUSE-Tumbleweed-Oss
Name : perl-Class-Accessor
Version : 0.51-1.24
Arch : noarch
Vendor : openSUSE
Installed Size : 40.7 KiB
Installed : No
Status : not installed
Source package : perl-Class-Accessor-0.51-1.24.src
Upstream URL : http://search.cpan.org/dist/Class-Accessor/
Summary : Automated accessor generation
Description :
This module automagically generates accessors/mutators for your class.
Most of the time, writing accessors is an exercise in cutting and pasting.
You usually wind up with a series of methods like this:
sub name {
my $self = shift;
if(@_) {
$self->{name} = $_[0];
}
return $self->{name};
}
sub salary {
my $self = shift;
if(@_) {
$self->{salary} = $_[0];
}
return $self->{salary};
}
One for each piece of data in your object. While some will be unique, doing
value checks and special storage tricks, most will simply be exercises in
repetition. Not only is it Bad Style to have a bunch of repetitious code,
but it's also simply not lazy, which is the real tragedy.
If you make your module a subclass of Class::Accessor and declare your
accessor fields with mk_accessors() then you'll find yourself with a set of
automatically generated accessors which can even be customized!
The basic set up is very simple:
package Foo;
use base qw(Class::Accessor);
Foo->mk_accessors( qw(far bar car) );
Done. Foo now has simple far(), bar() and car() accessors defined.
Alternatively, if you want to follow Damian's _best practice_ guidelines
you can use:
package Foo;
use base qw(Class::Accessor);
Foo->follow_best_practice;
Foo->mk_accessors( qw(far bar car) );
*Note:* you must call 'follow_best_practice' before calling 'mk_accessors'.