F
Ferry Bolhar
Hi,
in the Perl guts, a function like
sub {....}
is represented by a CV. The CvROOT/CvSTART fields
in the CV point the compiled OP tree where the CvPADLIST/
CvPADNAME fields point the scratch pad array (the "scope"
of the function).
In the case of named functions, the GvCV field of the GV (the
"typeglob") will point to the CV of the function. So, for a
function "hello", I can get a reference to its CV by writing
$hello_cv = *hello{CODE};
However, how can I locate the CV representing the "main"
function (the code outside any function)? There is a package
(stash) named "main::" but there is no function named like this.
Is there a way to find the main CV from Perl?
Kind greetings,
Ferry
in the Perl guts, a function like
sub {....}
is represented by a CV. The CvROOT/CvSTART fields
in the CV point the compiled OP tree where the CvPADLIST/
CvPADNAME fields point the scratch pad array (the "scope"
of the function).
In the case of named functions, the GvCV field of the GV (the
"typeglob") will point to the CV of the function. So, for a
function "hello", I can get a reference to its CV by writing
$hello_cv = *hello{CODE};
However, how can I locate the CV representing the "main"
function (the code outside any function)? There is a package
(stash) named "main::" but there is no function named like this.
Is there a way to find the main CV from Perl?
Kind greetings,
Ferry