Re: 'around' method modifier does not seem to work
[email protected] (Karen Etheridge) Thu, 6 Aug 2015 17:22:48 -0700
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <CAPJsHfBBD_vZBGa3u6Xi7FPR7Na-xEX6_KXpWRSX+jF1jraOYA@mail.gmail.com> |
--001a113cd95ab36650051cada256 Content-Type: text/plain; charset=UTF-8 On Thu, Aug 6, 2015 at 4:04 PM, Marcos Barbeitos <[email protected]> wrote: > around 'sequence' => sub > { > my $orig = shift; > my $self = shift; > my $sequence = uc shift; > > # Do lots of things with $sequence and then > > return $self->$orig( $sequence ); > } > > With no success, as expected. However, if I do: > > around 'sequence' => sub > { > my $orig = shift; > my $self = shift; > > return $self->$orig( @_ ); > } > > The attribute is set and life goes on. Of course, that does not work for me because I need to do a bunch of things to the argument passed to this method. The only difference I see between these two subs is the argument passed to $orig. So, have you tried printing it to check that it is what you expect it to be? --001a113cd95ab36650051cada256 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">On Thu, Aug 6, 2015 at 4:04 PM, Marcos Barbeitos <<a hr= ef=3D"mailto:[email protected]">[email protected]</a>> wrote:<br= >>=C2=A0=C2=A0=C2=A0=C2=A0 around 'sequence' =3D> sub<br>>= =C2=A0=C2=A0=C2=A0=C2=A0 {<br>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 my $orig =3D shift;<br>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 my $self =3D shift;<br>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 my $sequence =3D uc shift;<br>> <br>>=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Do lots of things with $sequence and th= en<br>> <br>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return = $self->$orig( $sequence );<br>>=C2=A0=C2=A0=C2=A0=C2=A0 }<br>> <br= >>=C2=A0=C2=A0=C2=A0=C2=A0 With no success, as expected. However, if I d= o:<br>> <br>>=C2=A0=C2=A0=C2=A0=C2=A0 around 'sequence' =3D&g= t; sub<br>>=C2=A0=C2=A0=C2=A0=C2=A0 {<br>>=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 my $orig =3D shift;<br>>=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 my $self =3D shift;<br>> <br>>=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return $self->$orig( @_ );<br>>= =C2=A0=C2=A0=C2=A0=C2=A0 }<br>> <br>>=C2=A0=C2=A0=C2=A0=C2=A0 The att= ribute is set and life goes on. Of course, that does not work for me becaus= e I need to do a bunch of things to the argument passed to this method.<br>= <br>The only difference I see between these two subs is the argument passed= to $orig.<br>So, have you tried printing it to check that it is what you e= xpect it to be?<br><br></div> --001a113cd95ab36650051cada256--