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