This generates a list of anonymous scalars:
\@{[]}[0..49]
Taking a reference to a slice yields a reference to each member (it's \ operating on a list). Generating one ref requires the same number of chars as Larry's, and is substantially slower. But if you ever need to generate a substantial list of scalar refs (it catches up at around 20, compared to using map with Larry's), this would be the way to go.

And with all due respect to Larry, here's a golfier way to get a single scalar ref:

\[]->[0]
Now, for the case you mention, in which you merely need a stateless object...well, you don't need an object. You just do everything through class methods. But taking a reference to a constant would work. You don't need an anonymous scalar, because you're not going to modify the contents.

You'd want a scalar when you have an object with only one property. In that case, you'd just declare a lexical scalar in your constructor, and bless a reference to it. So you still don't need anonymous scalars.


Caution: Contents may have been coded under pressure.

In reply to Re: On References to the Unnamed by Roy Johnson
in thread On References to the Unnamed by tlm

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.