Howdy, everybody, thank you so very much for your help. Ben was indeed correct; if I do:
around 'sequence' => sub { my $orig = shift; my $self = shift; if ( @_ == 1 ) { my $sequence = _get_parsed_sequence( shift ); return $self->$orig( $sequence ); } else { return $self->{sequence}; } }; I get it to work. Not a very elegant solution, for I must access the attribute directly instead of using an accessor. One issue still remains though, if I pass the argument to the constructor: my $collection = DCSE::Collection->new ( id => 'test' , sequence => $sequence , helix => $dcse->helix ); I believe that 'around' is not called, for I get the unparsed argument when I fetch the attribute. I will look into 'writers' and 'readers', maybe they will work better in this case? Cheers! On Fri, Aug 7, 2015 at 11:31 PM, Kent Fredric <kentfred...@gmail.com> wrote: > On 8 August 2015 at 09:09, Chris Prather <perig...@prather.org> wrote: > > If you check the part he quoted in the original email, that is in there. > > Obviously three of us missed it so maybe it could be highlighted better. > > > I think there's confusion stemming from there being *two* methods > being wrapped, one has the guard, and the other has its internals > elided, and we assume there is a guard. > > Method one is called "size": > > around 'size' => sub { > my $orig = shift; > my $self = shift; > > return $self->$orig() ##### Guard > unless @_; > > my $size = shift; > $size = $size / 2 > if $self->likes_small_things(); > > return $self->$orig($size); > }; > > > Method two is called "sequence": > > around 'sequence' => sub > { > my $orig = shift; > my $self = shift; > my $sequence = uc shift; > > # Do lots of things with $sequence and then > #### NO CLEAR GUARD > > return $self->$orig( $sequence ); > } > > > > And as he describes, the issue he experiences is predominantly with > the second of these, which makes sense, given there is no code that > *we* can see with the guard mechanism. > > > > -- > Kent > > KENTNL - https://metacpan.org/author/KENTNL > -- Marcos S. Barbeitos Departamento de Zoologia - Sala 360 Setor de Ciências Biológicas Universidade Federal do Paraná Caixa Postal 19020 Curitiba, PR 81531-990 Brazil Phone: (55 41) 3361-1634