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