I noticed today that TheDamian posted another way to do it namely:

$anon_scalar_ref = \eval{undef}; # or ... $anon_scalar_ref = \eval{ $init_val }; # if you prefer anon scalar in +itialized

Running:

#!/usr/bin/perl use strict; use warnings; use Devel::Size 'total_size'; use Devel::Peek; my $a = \"$$"; my $b = \""; my $c = \do {my $foo}; my $d = \eval{undef}; print total_size($a), "\n"; print total_size($b), "\n"; print total_size($c), "\n"; print total_size($d), "\n"; print "-----\n"; print Dump($a); print Dump($c); print Dump($d);
produced:
29 25 12 12 ----- SV = RV(0x1865b28) at 0x18242d8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x224f08 SV = PV(0x2251fc) at 0x224f08 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x1834234 "3484"\0 CUR = 4 LEN = 5 SV = RV(0x1865b30) at 0x18242e4 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x186168c SV = NULL(0x0) at 0x186168c REFCNT = 2 FLAGS = (PADBUSY,PADMY) SV = RV(0x1865b34) at 0x18247a4 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x224fbc SV = NULL(0x0) at 0x224fbc REFCNT = 1 FLAGS = ()


In reply to Re: On References to the Unnamed by eyepopslikeamosquito
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.