Perl Design Patterns Wiki

There’s a world of goodness over at the perl design patterns wiki. Take this little snippet:

foreach my $i (qw(name price quantity)) {
my $field = $i;
{"get_$field"} = sub {
my $me = shift;
return $me->{$field};
{"set$field"} = sub {
my $me = shift;
or die "not enough arguments to set_$field, stopped";
$me->{$field} = shift;
return 1;

..All your getters and setters, done. I’m in awe, and I’m dumping php and going back to perl :) This and other wisdom comes from the AccessorPattern page.