Bro. Doug has asked for the wisdom of the Perl Monks concerning the following question:
I check it like this and get an error message.package Bro::Doug ; use strict ; use warnings ; use warnings::register ; BEGIN{ no strict 'subs' ; my @ACCESSOR_METHODS = qw( one two three ) ; foreach my $i ( @ACCESSOR_METHODS ){ sub $i { my $self = shift ; if ( @_ ) { $self->{ uc $i } = shift @_ } return $self->{ uc $i } ; } } } sub new { my $class = shift ; my $self = {} ; bless ($self, $class) ; return $self ; } 1;
Does anyone know how to make this work right?% perl -cw Doug.pm > Illegal declaration of anonymous subroutine at Doug.pm line 58.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: declaring accessor methods from a list
by Joost (Canon) on Apr 26, 2007 at 22:32 UTC | |
|
Re: declaring accessor methods from a list
by Trizor (Pilgrim) on Apr 26, 2007 at 22:38 UTC | |
by Bro. Doug (Monk) on Apr 26, 2007 at 22:53 UTC | |
by Anonymous Monk on Apr 27, 2007 at 08:04 UTC | |
|
Re: declaring accessor methods from a list
by GrandFather (Saint) on Apr 26, 2007 at 22:13 UTC | |
|
Re: declaring accessor methods from a list
by AK108 (Friar) on Apr 27, 2007 at 01:22 UTC | |
|
Re: declaring accessor methods from a list
by ferreira (Chaplain) on Apr 27, 2007 at 11:31 UTC |