Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Ternary Quizical behaviour? (Ref vs Alias)

by LanX (Saint)
on Jul 10, 2020 at 21:51 UTC ( [id://11119165]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Ternary Quizical behaviour?
in thread Ternary Quizical behaviour?

> I don't think that's as common as you potentially think.

sometimes an example is clearer than many words:

the first arg to tst() is a scalar-ref, the second the scalar itself

DB<107> sub tst { print "ref of alias match: ".$_[0] if $_[0] == \ $ +_[1] ; $_[1] = 42 } DB<108> my $x =666; tst( \$x,$x); print "\n now x = $x" ref of alias match: SCALAR(0x339fb20) now x = 42

as you can see these are quite different concepts.

References are a datatype in Perl pointing to another thing.

Aliases are just the same thing by another symbolic name (sic).

And in fact, to prove it, that alias has even the identical reference!

compare also:

> never used the term alias to refer to a variable passed by reference.

well never too late! :)

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-16 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found