develooper Front page | perl.beginners | Postings from February 2010

make an alias to function

Thread Next
From:
Jeff Peng
Date:
February 15, 2010 23:19
Subject:
make an alias to function
Message ID:
35686be11002152319n5e7b5446i32850b9366727a4@mail.gmail.com
Hi,

I have a module, and I wanted to make an alias with a function in that module.

package abc;

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

But this won't work  when calling it:

my $obj = abc->new;
$obj->init_squid_for_reverseproxy;

The error says:
Can't locate object method "init_squid_for_reverseproxy" via package "abc" .

Why?


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

This works as I want. Is this the suitable one?

Thanks.

-- 
Jeff Peng
Email: jeffpeng@netzero.net
Skype: compuperson

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About