summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/dtracetoolkit/Notes/ALLperl_notes.txt
blob: 24039504f698e1e3f1413eb99a40cc73d2a2f6c3 (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 44 2007-09-17 07:47:20Z brendan $
*
* 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.

OpenPOWER on IntegriCloud