I have about ten routines that are common to a number of classes. These routines are kept in a package called Func. After profiling an application with DProf, I was surprised to find that most of the time is being spent in the BEGIN section of Func. Here is the output from the profiler:
Total Elapsed Time = -36.6621 Seconds User+System Time = 86.44528 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 28.4 24.62 28.883 738874 0.0000 0.0000 SE::Util::Func::BEGIN
Here is the top of the Func module:
package SE::Util::Func; use Exporter; @ISA = ('Exporter'); @EXPORT= qw( SE_cat SE_dump SE_getName SE_getValue SE_isTag SE_matchN +ame SE_matchNamePattern SE_prog SE_trim ); require 5.6.1; use strict;
Why is perl spending so much time in the BEGIN section of Func? Thanks.

In reply to Why is perl spending so much time in the BEGIN section? by erabus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.