Scalar::Defer does what you want.

Perfect! Many thanks. Think "defer" was one keyword I'd missed in all searching.

However, my advice is to reconsider and use a normal object instead. It will be much less confusing.

No doubt you're completely right but now I've started... ;) Actually, from glancing at Scalar::Defer and considering I want to do similar for arrays and hashes later, for which CPAN doesn't seem to have anything, that will probably be the end of it. The mission was to be able to replace a set of subroutines which execute queries immediately with "lazy" versions, simply be changing the module being used. Anyway - have learnt something.

BTW - you're not Perrin as in Perrin Harkins as in Krang are you? If so, we met at OSCOM.4 in Zurich a couple of years ago - was doing that talk on stuff like wrapping output from pod2html in PHP. Been meaning to drop you a "Hello" for a long time. Is this the right email - http://search.cpan.org/~perrin/


In reply to Re^2: Delay evaluation of tied scalar when returned from sub by harryf
in thread Delay evaluation of tied scalar when returned from sub by harryf

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.