X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FScope%2FUpper.pm;h=e36cbca5531e94fe1ce11339f0ed37b39d5746ed;hb=aadd0157199345b7e2570fa1d45d998479691b5e;hp=6ca286c47db5955d27f0f186b2443d06f56eacaa;hpb=4883814802ce13b05c096fdeefe987723fc3902f;p=perl%2Fmodules%2FScope-Upper.git diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm index 6ca286c..e36cbca 100644 --- a/lib/Scope/Upper.pm +++ b/lib/Scope/Upper.pm @@ -170,7 +170,11 @@ localize variables, array/hash values or deletions of elements in higher context =item * -return values immediately to an upper level with L, L and L, and know which context was in use then with L ; +return values immediately to an upper level with L, L and L ; + +=item * + +gather information about an upper context with L and L ; =item * @@ -339,6 +343,7 @@ Hence you can use it to return values from a C or a C block : } @things; Like for L, the upper context isn't coerced onto C<@values>. +You can use the fifth value returned by L to handle context coercion. =head2 C @@ -348,6 +353,8 @@ Like for L, the upper context isn't coerced onto C<@values>. Immediately returns C<@values> from the current block, whatever it may be (besides a C substitution context). C is actually a synonym for C, while C is a synonym for C. +Like for L, you can use the fifth value returned by L to handle context coercion. + =head2 C my $want = want_at; @@ -365,6 +372,65 @@ It can be used to revise the example showed in L : will rightfully set C<$num> to C<26>. +=head2 C + + my ($package, $filename, $line, $subroutine, $hasargs, + $wantarray, $evaltext, $is_require, $hints, $bitmask, + $hinthash) = context_info $context; + +Gives information about the context denoted by C<$context>, akin to what L provides but not limited only to subroutine, eval and format contexts. +When C<$context> is omitted, it defaults to the current context. + +The values returned are, in order : + +=over 4 + +=item * + +I<(index 0)> : the namespace in use when the context was created ; + +=item * + +I<(index 1)> : the name of the file at the point where the context was created ; + +=item * + +I<(index 2)> : the line number at the point where the context was created ; + +=item * + +I<(index 3)> : the name of the subroutine called for this context, or C if this is not a subroutine context ; + +=item * + +I<(index 4)> : a boolean indicating whether a new instance of C<@_> was set up for this context, or C if this is not a subroutine context ; + +=item * + +I<(index 5)> : the context (in the sense of L) in which the context (in our sense) is executed ; + +=item * + +I<(index 6)> : the contents of the string being compiled for this context, or C if this is not an eval context ; + +=item * + +I<(index 7)> : a boolean indicating whether this eval context was created by C, or C if this is not an eval context ; + +=item * + +I<(index 8)> : the value of the lexical hints in use when the context was created ; + +=item * + +I<(index 9)> : a bit string representing the warnings in use when the context was created ; + +=item * + +I<(index 10)> : a reference to the lexical hints hash in use when the context was created (only on perl 5.10 or greater). + +=back + =head2 C my @ret = uplevel { ...; return @ret }; @@ -623,7 +689,7 @@ Where L, L and L act depending on t # $cxt = SCOPE(4), UP SUB UP SUB = UP SUB EVAL = UP CALLER(2) = TOP ... -Where L, L, L and L point to depending on the C<$cxt>: +Where L, L, L, L and L point to depending on the C<$cxt>: sub { eval { @@ -646,7 +712,7 @@ Where L, L, L and L point to depending on t =head1 EXPORT -The functions L, L, L, L, L, L, L, L and L are only exported on request, either individually or by the tags C<':funcs'> and C<':all'>. +The functions L, L, L, L, L, L, L, L, L and L are only exported on request, either individually or by the tags C<':funcs'> and C<':all'>. The constant L is also only exported on request, individually or by the tags C<':consts'> and C<':all'>. @@ -662,7 +728,7 @@ our %EXPORT_TAGS = ( reap localize localize_elem localize_delete unwind yield leave - want_at + want_at context_info uplevel uid validate_uid > ],