CGI::FormMagick::Sub.3pm

Langue: en

Version: 2003-06-24 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

NAME

CGI::FormMagick::Sub - Call subs by name.

SYNOPSIS

     use CGI::FormMagick;
     my %sub = (
         package => $some_package_name,
         sub => $some_sub_name,
         args => \@array_of_args,
         comma_delimited_args => $string_of_comma_delimited_args,
     );
 
 
     $f = CGI::FormMagick->new();
 
 
     $f->sub_exists(%sub) or return undef;
     $f->sub_call(%sub);
 
 

DESCRIPTION

(Intended for internal use only.)

Used for calling subs whose names are dynamically generated. Note, FormMagick inherits from this class. It is never intended to be instantiated directly, and has no constructor. It's purpose is to provide methods, nothing more, like a mix-in class.

STATIC METHODS


sub_exists(...)

sub_exists() takes a hash with keys ``package'' and ``sub''. Returns true if the sub exists, false otherwise. ``package'' need not be defined. If the subroutine is not found in ``package'', or ``package'' is undef, the current object is searched using UNIVERSAL::can.

sub_call(...)

sub_call() takes a hash with keys ``package'' and ``sub'', and optional ``args'' and ``comma_delimited_args''. The ``comma_delimited_args'' are split up and pushed into the array of args to be sent to the sub when called. Returns the return of the called sub itself. ``package'' need not be defined. If the subroutine is not found in ``package'', or ``package'' is undef, the current object is searched using UNIVERSAL::can.

If the sub doesn't exist, it will throw a fatal exception with a stack backtrace.