NAME
Devel::Hints - Access compile-time hints at runtime
VERSION
This document describes version 0.03 of Devel::Hints, released February 5, 2003.
SYNOPSIS
use Devel::Hints ':all';
LABEL:
print cop_label(); # 'LABEL'
print cop_file(); # same as __FILE__
print cop_filegv(); # same as \$::{'_<' . __FILE__}
print cop_stashpv(); # same as __PACKAGE__
print cop_stash(); # same as \%{__PACKAGE__ . '::'}
print cop_seq(); # an integer
print cop_arybase(); # same as $[
print cop_line(); # same as __LINE__
use warnings;
print cop_warnings(); # same as compile-time ${^WARNING_BITS}
# cop_io() is only available to Perl 5.7 or above
use open IO => ':utf8';
print cop_io(); # same as compile-time ${^OPEN}
{
use IO => ':raw';
print cop_io(1); # access one uplevel; still ":utf8\0:utf8"
}
DESCRIPTION
This module exports the cop
struct as individual functions; callers can call them to find out the lexical-scoped hints that its block is compiled under.
No functions are exported by default. Each function may take an optional positive integer as argument, indicating how many blocks it should walk upward to obtain the cop
members.
FUNCTIONS
- cop_label
-
Label for the current construct.
- cop_file
-
File name for the current line.
- cop_filegv
-
Reference to the filehandle glob.
- cop_stashpv
-
The current package name.
- cop_stash
-
Reference to the current symbol table.
- cop_seq
-
Parse sequencial number.
- cop_arybase
-
Array base the calling line was compiled with.
- cop_line
-
The line number.
- cop_warnings
-
Lexical warnings bitmask, a.k.a.
${^WARNING_BITS}
. - cop_io
-
Lexical IO defaults, a.k.a.
${^OPEN}
.
ACKNOWLEDGMENTS
Thanks to Rafael Garcia-Suarez for demonstrating how to do this with the elegant Inline::C code on p5p, which I adapted to this less elegant XS implementation.
AUTHORS
Autrijus Tang <autrijus@autrijus.org>
COPYRIGHT
Copyright 2003 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.