It might be worth pointing out that even the module Readonly will - contrary to what one might expect - not prevent the internal structures from being modified by implicit type conversions. (In addition, the structures are more complex to start with.)  E.g.

use Devel::Peek; use Readonly; Readonly::Scalar my $number => 10; Dump($number); printf "Number is %d\n", $number; Dump($number); print "Number is $number\n"; Dump($number);

Output:

SV = PVMG(0x68ba80) at 0x65eb40
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,GMG,SMG,RMG)
  IV = 0
  NV = 0
  PV = 0
  MAGIC = 0x662c90
    MG_VIRTUAL = &PL_vtbl_packelem
    MG_TYPE = PERL_MAGIC_tiedscalar(q)
    MG_FLAGS = 0x02
      REFCOUNTED
    MG_OBJ = 0x63c410
    SV = RV(0x6ba0d0) at 0x63c410
      REFCNT = 1
      FLAGS = (ROK)
      RV = 0x6dc2e0
      SV = PVMG(0x68ba48) at 0x6dc2e0
        REFCNT = 1
        FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK)
        IV = 10
        NV = 0
        PV = 0
        STASH = 0x6dc120	"Readonly::Scalar"
Number is 10
SV = PVMG(0x68ba80) at 0x65eb40
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,GMG,SMG,RMG,pIOK)
  IV = 10
  NV = 0
  PV = 0
  MAGIC = 0x662c90
    MG_VIRTUAL = &PL_vtbl_packelem
    MG_TYPE = PERL_MAGIC_tiedscalar(q)
    MG_FLAGS = 0x02
      REFCOUNTED
    MG_OBJ = 0x63c410
    SV = RV(0x6ba0d0) at 0x63c410
      REFCNT = 1
      FLAGS = (ROK)
      RV = 0x6dc2e0
      SV = PVMG(0x68ba48) at 0x6dc2e0
        REFCNT = 1
        FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK)
        IV = 10
        NV = 0
        PV = 0
        STASH = 0x6dc120	"Readonly::Scalar"
Number is 10
SV = PVMG(0x68ba80) at 0x65eb40
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,GMG,SMG,RMG,pIOK,pPOK)
  IV = 10
  NV = 0
  PV = 0x6519b0 "10"\0
  CUR = 2
  LEN = 8
  MAGIC = 0x662c90
    MG_VIRTUAL = &PL_vtbl_packelem
    MG_TYPE = PERL_MAGIC_tiedscalar(q)
    MG_FLAGS = 0x02
      REFCOUNTED
    MG_OBJ = 0x63c410
    SV = RV(0x6ba0d0) at 0x63c410
      REFCNT = 1
      FLAGS = (ROK)
      RV = 0x6dc2e0
      SV = PVMG(0x68ba48) at 0x6dc2e0
        REFCNT = 1
        FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK)
        IV = 10
        NV = 0
        PV = 0
        STASH = 0x6dc120	"Readonly::Scalar"

_____

Update: ...similarly with Scalar::Readonly, btw  (though here the internal structures are as lean as without using the module):

use Devel::Peek; use Scalar::Readonly ':all'; my $number = 10; readonly_on($number); Dump($number); print "Number is $number\n"; Dump($number);
SV = IV(0x661dc8) at 0x65eb50
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,IOK,READONLY,pIOK)
  IV = 10
Number is 10
SV = PVIV(0x63e130) at 0x65eb50
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,IOK,POK,READONLY,pIOK,pPOK)
  IV = 10
  PV = 0x654fb0 "10"\0
  CUR = 2
  LEN = 8

In reply to Re^2: fork(): where does copy happen? by almut
in thread fork(): where does copy happen? 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.