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
Call::Context(3) User Contributed Perl Documentation Call::Context(3)

Call::Context - Sanity-check calling context

    use Call::Context;

    sub gives_a_list {

        #Will die() if the context is not list.
        Call::Context::must_be_list();

        return (1, 2, 3);
    }

    gives_a_list();             #die()s: incorrect context (void)

    my $v = gives_a_list();     #die()s: incorrect context (scalar)

    my @list = gives_a_list();  #lives

If your function only expects to return a list, then a call in some other context is, by definition, an error. The problem is that, depending on how the function is written, it may actually do something expected in testing, but then in production act differently.

"die()"s if the calling function is itself called outside list context. (See the SYNOPSIS for examples.)

This module throws instances of "Call::Context::X". "Call::Context::X" is overloaded to stringify; however, to keep memory usage low, "overload" is not loaded until instantiation.

https://github.com/FGasper/p5-Call-Context
2016-11-13 perl v5.32.1

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

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