From the looks of this B::Terse output it doesn't look like any optimisation is performed in this case
my $very = { nested => { hash => } }; $$very{nested}{hash} = "something" unless exists $$very{nested}{hash}; LISTOP (0x8109128) leave [1] OP (0x816c108) enter COP (0x81090f0) nextstate BINOP (0x8195f40) sassign UNOP (0x81090d0) srefgen UNOP (0x8195f18) null [141] LISTOP (0x8195ef0) anonhash OP (0x8109a48) pushmark SVOP (0x8109f20) const PV (0x8107d6c) "nested" UNOP (0x8109a68) srefgen UNOP (0x8104058) null [141] LISTOP (0x81872f0) anonhash OP (0x8187318) pushmark SVOP (0x81872d0) const PV (0x8107d90) + "hash" OP (0x8180df8) padsv [1] COP (0x816c0d0) nextstate UNOP (0x816c0b0) null LOGOP (0x816c088) or UNOP (0x816c068) exists UNOP (0x8109968) null [135] UNOP (0x8109948) rv2hv [3] BINOP (0x8109900) helem UNOP (0x81098c0) rv2hv OP (0x81098a0) padsv [1] SVOP (0x81098e0) const PV (0x8107dc0) "ne +sted" SVOP (0x8109928) const PV (0x8107dd8) "hash" BINOP (0x8109878) sassign SVOP (0x8109858) const PV (0x8107de4) "something" BINOP (0x8187c38) helem UNOP (0x8187c18) rv2hv [2] BINOP (0x8187bd0) helem UNOP (0x8187b90) rv2hv OP (0x8187b70) padsv [1] SVOP (0x8187bb0) const PV (0x8107d84) "ne +sted" SVOP (0x8187bf8) const PV (0x8107d78) "hash" - syntax OK

HTH

_________
broquaint


In reply to Re: Are common access expressions optimized? by broquaint
in thread Are common access expressions optimized? by John M. Dlugosz

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.