Oh yes, Devel::NYTProf is a fantastic tool!

Just for completeness, you can examine the OP codes generated for different snippets of Perl code via B::Terse. For example:

> perl -MO=Terse -e "sprintf q{%04d}, $_" (Windows) > perl -MO=Terse -e 'sprintf q{%04d}, $_' (Unix) LISTOP (0x254e078) leave [1] OP (0x2753080) enter COP (0x254e0b8) nextstate LISTOP (0x254e118) sprintf [2] OP (0x254e158) pushmark SVOP (0x254e1f8) const [3] PV (0x254f200) "%04d" UNOP (0x254e188) null [14] PADOP (0x254e1c0) gvsv GV (0xd6af50) *_ -e syntax OK > perl -MO=Terse -e "qq{$i$j$k$l}" (Windows) > perl -MO=Terse -e 'qq{$i$j$k$l}' (Unix) LISTOP (0x2806210) leave [1] OP (0x28061e0) enter COP (0x2806250) nextstate UNOP_AUX (0x28062b0) multiconcat [8] OP (0x28062f0) null [3] UNOP (0x664fe0) null [14] PADOP (0x665018) gvsv GV (0x65fbb0) *i UNOP (0x664f70) null [14] PADOP (0x664fa8) gvsv GV (0x6549e8) *j UNOP (0x664ec0) null [14] PADOP (0x664ef8) gvsv GV (0x65ff10) *k UNOP (0x2806360) null [14] PADOP (0x2806398) gvsv GV (0x654b68) *l -e syntax OK > perl -MO=Terse -e "$i.$j.$k.$l" (Windows) > perl -MO=Terse -e '$i.$j.$k.$l' (Unix) LISTOP (0x27d23b0) leave [1] OP (0x27d2380) enter COP (0x27d23f0) nextstate UNOP_AUX (0x27d2450) multiconcat [7] UNOP (0x25d2d70) null [14] PADOP (0x25d2da8) gvsv GV (0x25c4d78) *i UNOP (0x25d2d00) null [14] PADOP (0x25d2d38) gvsv GV (0x25c49b8) *j UNOP (0x25d2c50) null [14] PADOP (0x25d2c88) gvsv GV (0x25d01b0) *k UNOP (0x27d2490) null [14] PADOP (0x27d24c8) gvsv GV (0x25c4e38) *l -e syntax OK

No great surprise to see qq{$i$j$k$l} and $i.$j.$k.$l generating the same OP codes under the covers.

Updated: added Unix versions of perl command lines


In reply to Re^5: looping efficiency (B::Terse OP codes) by eyepopslikeamosquito
in thread looping efficiency by Anonymous Monk

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.