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  -  CLASS::UTIL (3)

.ds Aq ’

NAME

Class::Util - Class utility functions

CONTENTS

VERSION 2.21

Included in OOTools 2.21 distribution.

The latest versions changes are reported in the Changes file in this distribution.

The distribution includes:
o Class::constr

Pragma to implement constructor methods

o Class::props

Pragma to implement lvalue accessors with options

o Class::groups

Pragma to implement groups of properties accessors with options

o Class::Error

Delayed checking of object failure

o Object::props

Pragma to implement lvalue accessors with options

o Object::groups

Pragma to implement groups of properties accessors with options

o Class::Util

Class utility functions

INSTALLATION

Prerequisites


    Perl version >= 5.6.1



CPAN


    perl -MCPAN -e install OOTools



Standard installation From the directory where this file is located, type:



    perl Makefile.PL
    make
    make test
    make install



SYNOPSIS



  use Class::Util;
  use Class::Util qw(load gather blessed);
 
  # will require Any::Module from a variable
 
  $module = Any::Module;
  load $module;
 
  $_ = Any::Module
  load;
 
  %defaults = gather { %$_ } %default;
 
  $class = blessed $object or die Not a blessed object



DESCRIPTION

This is a micro-weight module that (right now) exports only a few functions of general utility in Class operations.

FUNCTIONS

load [ CW$any_class ]

This function will require the any_class and will croak on error. If no argument is passed it will use $_ as the argument. It is aware of the classes that have been loaded or declared in other loaded files, so it doesn’t croak if the symbol table of the class is already defined, anyway you can check that by checking $@.

It is useful if you need to load any module from a variable, since it avoids you to do:



   eval "require $class";
   if ( $@ ) { check_what_error and croak $@ };



gather {CODE} CW$symbol [, CW$classes ]

The gather function executes the <CODE> block for each defined $symbol found in $classes, setting $_ as the reference to the found symbol and returns the list of results. $symbol must be a string starting with *&%@$; $classes may be a reference to an ARRAY of classes, a class name, or a blessed object. If $classes is omitted it uses the classes of the caller; if it is a scalar it consider it as a class and uses the classes of that class.

This function is very useful if you want to implement data inheritance or if you want to implement overrunning, that is running the same method for each package that defines it (see for example Overrunning in CGI::Builder).



   # data inheritance example
   package RemoteBase;
   our %default = ( a=>1, b=>2 );
  
   package TheBase;
   our %default = (a=>10, c=>3);
  
   package main;
   use Class::Util qw(gather);
   our @ISA = qw(TheBase RemoteBase);
   our %default = ( d=>5 );
  
   my %defaults = gather { %$_ } %default ;
  
   print Dumper \%defaults ;

   # will print
   $VAR1 = { a => 10,
             b => 2,
             c => 3,
             d => 5
           };



    classes [$class|$object]

This function returns the list of all the classes that compose an object or a class (included the class itself). In scalar context it returns a reference to an ARRAY. If no arguments are passed it uses the caller package.

The returned classes are ordered from the more remote class to the class itself (included).

<B>NoteB>: The result of this function is the reversed @ISA path that perl uses in order to find methods; the only exception is the UNIVERSAL class, which is always omitted: if you need it unshift it to the result.

    blessed [$object]

This function returns the blessed class of $object ONLY if the object is blessed. It returns the undef value if $object is not blessed. If $object is omitted it uses $_.

SUPPORT

If you need support or if you want just to send me some feedback or request, please use this link: http://perl.4pro.net/?Class::Util.

AUTHOR and COPYRIGHT

X 2004-2005 by Domizio Demichelis.

All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as perl itself.

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 239: Non-ASCII character seen before =encoding in ’X’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::UTIL (3) 2012-03-05

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