in reply to Re^2: Singleton method wrappers for config file properties: Bad idea?
in thread Singleton method wrappers for config file properties: Bad idea?

I don't have to manually write a new accessor method.

I don't think you necessarily do, either of these should work (untested):

my @props = qw/ foo bar quz /; for my $name (@props) { has $name => ( is => 'ro', ... ); } # - or - has [@props] => ( is => 'ro', ... );

Of course, if your config elements are different, then yeah, you'll have to account for those differences by adding new and different properties to your class for each one. That's part of the price you pay for using OO over a hashref, but you do gain some things (subclassing, argument checking, etc.).

  • Comment on Re^3: Singleton method wrappers for config file properties: Bad idea?
  • Download Code