+ "uid"
+ my $uid = uid;
+ my $uid = uid $context;
+
+ Returns an unique identifier (UID) for the context (or dynamic scope)
+ pointed by $context, or for the current context if $context is omitted.
+ This UID will only be valid for the life time of the context it
+ represents, and another UID will be generated next time the same scope
+ is executed.
+
+ my $uid;
+
+ {
+ $uid = uid;
+ if ($uid eq uid()) { # yes, this is the same context
+ ...
+ }
+ {
+ if ($uid eq uid()) { # no, we are one scope below
+ ...
+ }
+ if ($uid eq uid(UP)) { # yes, UP points to the same scope as $uid
+ ...
+ }
+ }
+ }
+
+ # $uid is now invalid
+
+ {
+ if ($uid eq uid()) { # no, this is another block
+ ...
+ }
+ }
+
+ For example, each loop iteration gets its own UID :
+
+ my %uids;
+
+ for (1 .. 5) {
+ my $uid = uid;
+ $uids{$uid} = $_;
+ }
+
+ # %uids has 5 entries
+
+ The UIDs are not guaranteed to be numbers, so you must use the "eq"
+ operator to compare them.
+
+ To check whether a given UID is valid, you can use the "validate_uid"
+ function.
+
+ "validate_uid"
+ my $is_valid = validate_uid $uid;
+
+ Returns true if and only if $uid is the UID of a currently valid context
+ (that is, it designates a scope that is higher than the current one in
+ the call stack).
+
+ my $uid;
+
+ {
+ $uid = uid();
+ if (validate_uid($uid)) { # yes
+ ...
+ }
+ {
+ if (validate_uid($uid)) { # yes
+ ...
+ }
+ }
+ }
+
+ if (validate_uid($uid)) { # no
+ ...
+ }
+