>>>>> "JP" == Jeff Peng <[email protected]> writes:
>>>>> "JP" == Jeff Peng <[email protected]> writes:

  JP> package abc;

  JP> { # make an alias to another function
  JP>    no strict 'refs';
  JP>    *{__PACKAGE__::init_squid_for_reverseproxy} = \&init_reverseproxy;
  JP> }

<output is edited>

perl -e '*{__PACKAGE__::foo} = \&bar; print map "$_\n", keys %main::'
__PACKAGE__::



you created a class called __PACKAGE__! so the alias is not in main::
(or whatever the current package is) but in the literal package
'__PACKAGE__'.

that token has to be on its own to be the actual package name. it would
work if you did:

*{ __PACKAGE__ . '::init_squid_for_reverseproxy' } = \&init_reverseproxy;

since the builds up a string for the fully qualified name of the alias.



  JP> OK I simply updated the alias definition to:
  JP> *init_squid_for_reverseproxy = \&init_reverseproxy;

if you are aliasing to the same package, that is the easiest way to do
it. no need to deal with symrefs or turn off strict.

uri

-- 
Uri Guttman  ------  [email protected]  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to