#!/bin/sh -- # A comment mentioning perl, indented bash's sake. eval 'exec perl -S $0 ${1+"$@"}' if 0; $SafeStart = 1; chop($Program = `basename $0`); $Usage = <<"END"; $Program: Count subroutine calls that a perl script makes. Usage: $Program [] [] Options: -q Be quiet. -b Batch mode (no prompting). -h Print this help. END $NewScript = "/tmp/$Program.$$"; open(PROF, ">$NewScript") || die "open for writing: $!"; LOOP: while (@ARGV) { $_ = shift; CASE: { /^-q$/ && ($Quiet = 1, last CASE); /^-b$/ && ($Batch = 1, last CASE); /^-(-.*)$/ && (unshift(@ARGV, $1), last CASE); /^(-h|-help)$/ && ((print $Usage), exit 0, last CASE); if ( /^-(..+)$/ ) { # split bundled switches: local($y, $x) = ($1, ''); foreach $x (reverse(split(//, $y))) { unshift(@ARGV,"-$x") }; last CASE; } /^-/ && ((print "Invalid arg: $_\n$Usage"), exit 1, last CASE); unshift(@ARGV,$_); last LOOP; } } $CmdFile = shift; if ( $CmdFile !~ m,/, ) { foreach $dir (split(/:/, $ENV{PATH})) { if ( -x "$dir/$CmdFile" ) { $CmdFile = "$dir/$CmdFile"; last; } } } die "Cannot find command file: $CmdFile" if ! -x $CmdFile; print STDERR "$Program: Using $CmdFile\n" unless $Quiet; open(SCRIPT, "$CmdFile") || die "open for reading: $!"; while (