fritz1968 has asked for the wisdom of the Perl Monks concerning the following question:
package LDAPclient; use Moose; my @ldap_attrs = qw( ssl host port retry timeout version loginID loginPW logging ); for my $name (@ldap_attrs) { my $reader = 'get_' . $name; my $writer = 'set_' . $name; has $name => ( is => 'rw', reader => $reader, writer => $writer, required => 0 ); }
I want to set default values for ssl, port, retry, timeout, version and logging... but I don't want to have 5 different "has" lines with each having the is, reader, writer, required and default parts. Is there a way to set a default for a value outside of the above loop? If so, I would appreciate an example.
thanks, frank
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose and OOP in Perl
by moritz (Cardinal) on May 09, 2013 at 20:00 UTC | |
|
Re: Moose and OOP in Perl
by tobyink (Canon) on May 09, 2013 at 21:35 UTC |