Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: Shouldn't references be readonly?

by jo37 (Friar)
on Aug 05, 2020 at 18:11 UTC ( #11120335=note: print w/replies, xml ) Need Help??


in reply to Re^4: Shouldn't references be readonly?
in thread Shouldn't LITERAL references be readonly? (updated)

Isn't an alias something dereferenced into a symbol table entry? So a reference and an alias are on different levels of indirection.

DB<1> use Scalar::Util 'readonly' DB<2> p readonly 1 134217728 DB<3> p readonly \1 0 DB<4> *one = \1 DB<5> p readonly $one 134217728 DB<6> $rone = \1 DB<7> p readonly $$rone 134217728 DB<8> $one = 2 Modification of a read-only value attempted at (eval 16)[/usr/share/pe +rl/5.20/perl5db.pl:732] line 2. DB<9> $$rone = 2 Modification of a read-only value attempted at (eval 17)[/usr/share/pe +rl/5.20/perl5db.pl:732] line 2.

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^6: Shouldn't references be readonly?
by LanX (Cardinal) on Aug 05, 2020 at 18:20 UTC
    • alias

      A nickname for something, which behaves in all ways as though you’d used the original name instead of the nickname. Temporary aliases are implicitly created in the loop variable for foreach loops, in the $_ variable for map or grep operators, in $a and $b during sort’s comparison function, and in each element of @_ for the actual arguments of a subroutine call. Permanent aliases are explicitly created in packages by importing symbols or by assignment to typeglobs. Lexically scoped aliases for package variables are explicitly created by the our declaration.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      This a lame description of aliases. See Symbol Tables.

      Greetings,
      -jo

      $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
        Nope typeglobs are only one of many possibilities to have aliases.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11120335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-10-23 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (232 votes). Check out past polls.

    Notices?