GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  UNIVERSAL::WHICH (3)

.ds Aq ’

NAME

UNIVERSAL::which - tells fully qualified name of the method

CONTENTS

VERSION

$Id: which.pm,v 0.6 2007/05/15 16:01:20 dankogai Exp dankogai $

SYNOPSIS



  use UNIVERSAL::which;
  use Some::Sub::Class; # which inherits lots of modules
  # ....
  my $o   = Some::Sub::Class->new;
  # in scalar context
  my $fqn = $o->which("method");
  # in list context
  my ($pkg, $name) = $o->which("method");
  # as function
  my $fqn = UNIVERSAL::which(Some::Sub::Class, method);



DESCRIPTION

UNIVERSAL::which provides only one method, which.

As the name suggests, it returns the fully qualified name of a given method. Sometimes you want to know the true origin of a method but inheritance and AUTOLOAD gets in your way. This module does just that.

t/*.t illustrates how UNIVERSAL::which behaves more in details.

    CAVEAT

Consider the code below;



  no warnings once;
  package Foo;
  my $code = sub { 1 };
  package Bar;
  *muge = $code;



In this case, you get undef for $fq = Bar>which(muge) while ($pkg, $name) = Bar->which(muge) is (Foo, __ANON__).

That way the code snippet works as expeted.



  my $fq = Bar->which(muge); &$fg if $fg;



if you get ’Bar::__ANON__’ instead, perl will croak on you at the 2nd line.

SEE ALSO

perlobj, UNIVERSAL::canAUTOLOAD

AUTHORS

Dan Kogai, <dankogai at dan.co.jp> <http://search.cpan.org/~dankogai/>

Original idea seeded by: TANIGUCHI <http://search.cpan.org/~taniguchi/>

B::svref_2object trick by: HIO <http://search.cpan.org/~hio/>

AUTOLOAD case suggested by: DAIBA <http://search.cpan.org/~daiba/>

Anon. coderef bug noted by: MIYAZAKI <http://search.cpan.org/~miyazaki/>

COPYRIGHT AND LICENSE

Copyright (C) 2006-2007 by Dan Kogai

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 UNIVERSAL::WHICH (3) 2007-05-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.