1************************************************************************** 2* The following are notes for all the Perl tracing scripts, 3* 4* $Id: ALLperl_notes.txt,v 1.1.1.1 2015/09/30 22:01:08 christos Exp $ 5* 6* COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 7************************************************************************** 8 9 10* Where did those "BEGIN" subroutine calls come from? 11 12The 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 19no subroutines were called, so there is no data to output. 20 21Now a similar program is traced, Code/Perl/hello_strict.pl, which uses 22the "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 32not only were functions from "strict.pm" traced, but a "BEGIN" function 33ran 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 42Perl appears to add a BEGIN block to process the "use" keyword. This makes 43some degree of sense. 44 45