Contextual::Call - call sub with caller's context


Contextual-Call documentation  | view source Contained in the Contextual-Call distribution.

Index


NAME

Top

Contextual::Call - call sub with caller's context

VERSION

Top

Version 0.01

SYNOPSIS

Top

 use Contextual::Call qw(ccall);

 # invoke sub with your context.
 my $cc = ccall($coderef);

 ... some processes ..

 # and return value which was returned by $coderef and 
 # is matched with context.
 return $cc->result;

DESCRIPTION

Top

ccall function can invoke a function undef specified context (default is caller's context) and reproduce return value of that invocation.

This function is useful when you will override a method which returns different values between scalar and list context.

EXPORT

Top

This module can export ccall function.

FUNCTIONS

Top

ccall

 $cc = ccall($coderef);

Call specified code-ref with your context, and return a Contextual::Call object which contains result of that call. You can get the result appropriate for context.

This function is shortcut to new constructor.

CONSTRUCTOR

Top

new

 $obj = Contextual::Call->new({ context => wantarray, sub => $coderef });

Call specified code-ref with your context, and return a Contextual::Call object. This method is OO-style of ccall function.

METHODS

Top

result

 return $obj->result();

Return result value with same context with ccall/new.

AUTHOR

Top

YAMASHINA Hio, <hio at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-contextual-call at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Contextual-Call. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.



    perldoc Contextual::Call

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Contextual-Call

* CPAN Ratings

http://cpanratings.perl.org/d/Contextual-Call

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Contextual-Call

* Search CPAN

http://search.cpan.org/dist/Contextual-Call

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Contextual-Call documentation  | view source Contained in the Contextual-Call distribution.