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