blob: aebe157fc1b997acb77849e2892aa0a96a08b45f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
**************************************************************************
* The following are notes for all the Perl tracing scripts,
*
* $Id: ALLperl_notes.txt,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
*
* COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
**************************************************************************
* Where did those "BEGIN" subroutine calls come from?
The following counts subroutines from the example program, Code/Perl/hello.pl,
# pl_subcalls.d
Tracing... Hit Ctrl-C to end.
^C
FILE SUB CALLS
no subroutines were called, so there is no data to output.
Now a similar program is traced, Code/Perl/hello_strict.pl, which uses
the "strict" pragma,
# pl_subcalls.d
Tracing... Hit Ctrl-C to end.
^C
FILE SUB CALLS
hello_strict.pl BEGIN 1
strict.pm bits 1
strict.pm import 1
not only were functions from "strict.pm" traced, but a "BEGIN" function
ran from the "hello_strict.pl" program - which doesn't appear to use "BEGIN",
# cat -n ../Code/Perl/hello_strict.pl
1 #!./perl -w
2
3 use strict;
4
5 print "Hello World!\n";
Perl appears to add a BEGIN block to process the "use" keyword. This makes
some degree of sense.
|