Devel-LexAlias

 view release on metacpan or  search on metacpan

LexAlias.pm  view on Meta::CPAN

into the pad as implied by the name of the variable, so it is possible
to do the following:

 lexalias( $sub, '$foo', [qw(an array)] );

The behaviour of this is untested, I imagine badness is very close on
the horizon though.

=head1 SEE ALSO

peek_sub from L<PadWalker>, L<Devel::Peek>

=head1 AUTHOR

Richard Clamp E<lt>richardc@unixbeard.netE<gt> with close reference to
PadWalker by Robin Houston

=head1 COPYRIGHT

Copyright (c) 2002, 2013, Richard Clamp. All Rights Reserved.  This module
is free software. It may be used, redistributed and/or modified under
the same terms as Perl itself.

=cut

LexAlias.xs  view on Meta::CPAN

# define PadlistARRAY(pl)      ((PAD **)AvARRAY(pl))
# define PadlistNAMES(pl)      (*PadlistARRAY(pl))
# define PadnamelistARRAY(pnl) ((PADNAME **)AvARRAY(pnl))
# define PadnamelistMAX(pnl)   AvFILLp(pnl)
# define PadARRAY              AvARRAY
# define PadnamePV(pn)         (SvPOKp(pn) ? SvPVX(pn) : NULL)
#endif



/* cargo-culted from PadWalker */

MODULE = Devel::LexAlias                PACKAGE = Devel::LexAlias

void
_lexalias(SV* cv_ref, char *name, SV* new_rv)
  CODE:
{
    CV*          cv   = SvROK(cv_ref) ? (CV*) SvRV(cv_ref) : NULL;
    PADNAMELIST* padn = cv ? PadlistNAMES(CvPADLIST(cv)) : PL_comppad_name;
    PAD*         padv = cv ? PadlistARRAY(CvPADLIST(cv))[1] : PL_comppad;



( run in 0.547 second using v1.01-cache-2.11-cpan-05444aca049 )